How to: Enable Incremental Collection Updates With PowerShell

ConfigMgr 2007 R3 shipped with a feature called Incremental Updates for collections, and ConfigMgr 2012 also supports this feature. From the official docs, here’s what incremental updates do for you:

Select this option to periodically scan for only new or changed resources from the previous collection evaluation and update the collection membership with only these resources, independently of a full collection evaluation. By default, incremental updates occur at 10 minute intervals.

This post will demonstrate how to identify collections with incremental updates enabled, as well as how to enable incremental updates for a collection.

Here’s an example to list all collections that have incremental updates enabled:

#display collections with incremental updates enabled
#replace mycfgmgrlab with site server name, LAB with Site code
gwmi sms_collection -computer mycfgmgrlab `
  -namespace root\sms\site_LAB | foreach {
  $Coll = [wmi] $_.__Path
  if ($Coll.RefreshType -eq 6) {
        write-host $Coll.CollectionID "`t" $Coll.Name
    }
}

Since RefreshType is a lazy property, you must take some extra steps. use get-wmiobject (alias is gwmi) to get all collections, then perform a for-each loop to use query the instance directly using the [wmi] accelerator for PowerShell. Finally, check to see if RefreshType = 6.

Here’s an example to enable incremental updates on a collection:


#enable incremental updates on a collection
#replace mycfgmgrlab with site server name, LAB with Site code,
#and LAB007DE with desired collecitonid
$a = [wmi] "\\mycfgmgrlab\root\sms\site_LAB:SMS_Collection.CollectionID='LAB007DE'"
$a.RefreshType = 6
$a.put()

Use the [WMI] accelerator to grab the specific instance with lazy properties, and set RefreshType = 6

Valid values for RefreshType:

  • 6 = Incremental and Periodic Updates
  • 4 = Incremental Updates Only
  • 2 = Periodic Updates only
  • 1 = Manual Update only

For more information about Incremental Updates, review’ the Microsoft page for Creating Collections in ConfigMgr 2012 (expand the node “To Create a Device Collection” to see the details.) Also note that the following classes do not support incremental updates:

  • SMS_G_System_CollectedFile
  • SMS_G_System_LastSoftwareScan
  • SMS_G_System_AppClientState
  • SMS_G_System_DCMDeploymentState
  • SMS_G_System_DCMDeploymentErrorAssetDetails
  • SMS_G_System_DCMDeploymentCompliantAssetDetails
  • SMS_G_System_DCMDeploymentNonCompliantAssetDetails
  • SMS_G_User_DCMDeploymentCompliantAssetDetails (for collections of users only)
  • SMS_G_User_DCMDeploymentNonCompliantAssetDetails (for collections of users only)
  • SMS_G_System_SoftwareUsageData
  • SMS_G_System_CI_ComplianceState
  • SMS_G_System_EndpointProtectionStatus
  • SMS_GH_System_*
  • SMS_GEH_System_*

More information about Lazy Properties:

Greg

 

[edit 6/18/2012 to add 4=Incremental Updates Only – Thanks Josef!]

How To: Enable the “Suppress Program Notifications” Checkbox for all Programs in a Package

In a previous post, I wrote how to enable the “Suppress Program Notifications” Checkbox for Program Properties for all programs in your environment. By request, in this post we’re going to modify the script slightly to modify all programs for one package, given the PackageID.

#Select all programs for one package
#(Update MySiteServer and LAB with your ConfigMgr Server name and Site code, and PackageID with a valid packageID)
$prgs = get-wmiobject sms_program -computername MySiteServer -namespace root\sms\site_LAB -filter "PackageID='LAB0023C'"
$prgs | foreach {
#ProgramFlags are a lazy property, so make explicit call.
$prg = [wmi] $_.__Path
if ($prg.ProgramFlags -band ([math]::pow(2,10)))
{
# Suppress already enabled
}
else
{
# Not suppressed - display programname and packageID
$prg.Programname + "`t" + $prg.PackageiD
# flip the programflags bit to enable suppression
$prg.ProgramFlags = $prg.ProgramFlags -bor ([math]::pow(2,10))
# use Put to save changes
$prg.put()
}
#rinse and repeat
}

The only change we had to make was to add the filter command to the get-wmiobject cmdlet. -filter “PackageID=’LAB0023C'”

 Read more about SMS_Program and ProgramFlags.

Greg