Most Popular Posts

Saturday, 12 October 2013

Powershell - Enable incremental updates on collections

I am busy at the moment migrating a customer from SCCM 2007 to 2012, as part of the migration I disabled incremental updates on all collections so as not to hurt performance. The customer has a folder of collections that they use to deploy software via active directory groups, all collections are prefixed "AD Deploy". They wanted to enable scheduled & incremental updates on these collections only so I set to do this with powershell, disappointed that there was no cmdlet for this I turned to WMI.

Using the SMS_Collection class from the SMS namespace I was able to filter on collections begining with "AD Deploy" and set the property (RefreshType in this case) to a value of 6, which would enable incremental and scheduled updates. Below is the script I came up with.


#======Start Script==============
$Collections = (Get-WmiObject -Class SMS_Collection -Namespace "root\SMS\site_007" -ComputerName . -Filter "Name Like 'AD Deploy%'")

$Count = 0
foreach ($Col in $Collections){
$Col.RefreshType = 6
$Col.put() | Out-Null
Write-Host $Col
write-host $Col.Name
$Count ++
}
write-host $Count "collections in total"

#=========End Script===========

Here is a link to the script

You can change the filter for collections in your environment if you wish to use it, I would also recommend commenting out the "$Col.put() | Out-Null" line for the first run and do a manual check/count of the collections that this might actually affect ;)

Hope it helps someone out there :)

Wayne