Modifying ConfigMgr 2012 Package Properties

ConfigMgr-2012

There are times when it is necessary to access settings in Configuration Manager via WMI in order to automate the alteration of settings using something like VBScript or PowerShell. One of those times is when we add our 1E Nomad software to an existing ConfigMgr 2012 implementation and we want to go back and update existing packages to make use of Nomad.

In the past we have written scripts that make such modifications for ConfigMgr 2007 which work perfectly. I recently tested such a script against ConfigMgr 2012 and was promptly faced with an error for every package the script tried to process.

Manually looking through the packages on the server I found that if I tried to modify the “Configuration Manager Client Package” package (which is created on installation) the majority of settings were unavailable The comment for the package indicated that it had been automatically created.

Every time I ran my script I received a -2147217407 error for the first package it processed (the order is determined by the Package ID number, which was for the “Configuration Manager Client Package“) and I also received it for every package that was subsequently processed.

I searched the Internet and wasn’t able to find any applicable information concerning why my script would have resulted in this error, so I cracked open the trusty WMICodeCreator program and started looking through WMI to see what might be causing my issue.

On ConfigMgr 2012 I noticed a property in the SMS_Package class called IsPredefinedPackage. The property does not exist for ConfigMgr 2007. When I executed the WMICodeCreator code against this property (on ConfigMgr 2012) I found that the “Configuration Manager Client PackageIsPredefinedPackage property was set to True. For other packages that I had created the property was set to False.

I added code to my script to check the IsPredefinedPackage property for each package before trying to make any alterations and used the result to skip any packages where the value was True. After running the updated script the “Configuration Manager Client Package” was skipped and the other packages which were not predefined were altered successfully, returning an error code of 0.

For some reason, when I encountered the -2147217407 error when processing the first package in the list I ended up with the same error for every package after that, but when I evaluated the IsPredefinedPackage property I was able to successfully process every package that was not predefined. In order to properly script modifications to ConfigMgr 2012 packages you will have to account for the IsPredefinedPackage property.

This is something to keep in mind when working with ConfigMgr 2012 packages through WMI scripts.

Share this post

Share this post on your favourite social media platform.

Find this article useful?

If so please click here