SCCM 2012 Update existing collection schedule using Powershell

I found many articles how to set collection schedule for new collection, but unfortunately I didn’t found one that can describe me how to change existing schedule for collection. So I maintain own script. It’s quick and dirty.

#Import SCCM module
Import-Module 'D:\Program Files\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1'

# TT1 - SCCM Site Code
cd TT1:

# usercolls will keep filtered collection that we would like to changeSchedule, in my case there was "AppInst" string in Name
$usercolls = (Get-CMUserCollection | ?{$_.Name -like "*AppInst*" })

foreach ($coll in $usercolls){
# moreinfo about schedule - I randomized minutes and seconds for refresh, beacuse I choosed hourly interval, so there won't be mass query to DB for every hour at exactly same time
$newsched = New-CMSchedule -Start $((Get-Date).AddMinutes($(Get-Random -Minimum 0 -Maximum 59)).AddSeconds($(Get-Random -Minimum 0 -Maximum 59))) -DurationInterval Hours -RecurCount 1 -DurationCount 0 -RecurInterval Hours

$wcol = $coll.psbase.managedobject
$wsched = $newsched.psbase.managedobject

$wcol.RefreshSchedule = $wsched


I hope that it will be helpful for you!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


× nine = forty five