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

$wcol.put()
}

I hope that it will be helpful for you!