Outbound call routing time condition

In order to create an outbound route policy based on a time condition in order to prevent certain users from making PSTN calls after working hours

you need to do them with powershell script and windows task scheduler


so the example below shows that i created two voice policies one called "WorkTime" and the other one is "AfterWork"

and assigned routing for working time as well as disabling all the PSTN routes from the "AfterWork"

Now i created 2 scripts at the c:\ root folder; first is wt.ps1 and that contains the wroking time policy

  #Import-Module lync

#Grant-CsVoicePolicy –Identity "Ken Myer" –PolicyName "WorkTime"

#Grant-CsVoicePolicy –Identity "Adam Barr" –PolicyName "WorkTime"  


and the aw.ps1 which containg the after work policy

#Import-Module lync

#Grant-CsVoicePolicy –Identity "Ken Myer" –PolicyName "AfterWork"

#Grant-CsVoicePolicy –Identity "Adam Barr" –PolicyName "AfterWork"


now from the Task Scheduler i had to create a task job  at 9:00 AM with the CSAdministrator credential that runs the Working time script, as well as the after work script at 5:00 PM


Voila! Now i tested it on my demo machine and it works like charm!