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 is a systems engineer specializing in global systems management for Dell IT. He has a B.S. in Computer Sciences and Engineering from the Ohio State University and is a Microsoft Most Valuable Professional (MVP) for Microsoft System Center Configuration Manager. Greg coauthored SMS 2003 Recipes: A Problem-Solution Approach (Apress, 2006), Microsoft System Center Configuration Manager Unleashed (Sams, 2009), Microsoft System Center 2012 Configuration Manager Unleashed (Sams, 2012), and Microsoft System Center 2012 Configuration Manager: Administration Cookbook (Packt Publishing, 2012), and Microsoft System Center 2012 Configuration Manager R2 Unleashed (Sams, 2012). Greg is cofounder of the Ohio SMS Users Group, and the Central Texas Systems Management User Group.

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

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: