How To: List Packages that are Configured to use a Package Share in ConfigMgr 2012

Here’s a sample script to display all packages that have the option enabled to “Copy the content in this package to a package share on distribution points.”

get-cmpackage | foreach {
  if ($_.pkgflags -eq ($_.pkgflags -bor 0x80)) {
  "pkg share bit enabled on {0}" -f $_.Packageid
  }
}

To run the script, launch PowerShell from your ConfigMgr Admin Console, or import the ConfigMgr module, and paste it into the command screen or run it as a .ps1 file.  As you can see, we run get-cmpackage to query for all packages on the ConfigMgr site. You will noticed that get-cmpackage may take some time to run in an environment with a large number of packages, because it is also querying the lazy properties for each package. Next we run a for-each loop to check the package flags. We then use the bitwise operator -bor to compare the current pkgflags value to see if the value 0x80 has already been applied, and display a message if it finds the checkbox enabled.

You can find more information about pkgflags on msdn.

For reference, here’s the setting on the package:
pkgshareproperty

Happy Scripting,

 

Greg

 

About Greg Ramsey
Greg Ramsey, Enterprise Mobility MVP, is a Senior Enterprise Architect at Dell Technologies. He has a B.S. in Computer Sciences and Engineering from Ohio State University and has co-authored many books over the years. Greg is an international speaker, a board member of the Northwest System Center User Group, and the Director of Communications for the Midwest Management Summit.

2 Responses to How To: List Packages that are Configured to use a Package Share in ConfigMgr 2012

  1. MikhailCompo says:

    This script is useful thanks greg – However, it is very very slowwwwwww

    Is there any way to improve performance on our 600 packages?!

    • Greg Ramsey says:

      Yes. You can query wmi directly.

      Just replace LAB with your sitecode, and myLAB with the site server name.

      gwmi sms_package -Namespace root\sms\site_LAB -ComputerName myLAB | foreach {
      if ($_.pkgflags -eq ($_.pkgflags -bor 0x80)) {
      “pkg share bit enabled on {0}” -f $_.Packageid
      }
      }

Leave a Reply to Greg Ramsey Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: