How To: List Packages that are Configured to use a Package Share in ConfigMgr 2012
February 14, 2013 2 Comments
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:
Happy Scripting,
Greg
This script is useful thanks greg – However, it is very very slowwwwwww
Is there any way to improve performance on our 600 packages?!
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
}
}