Wednesday, April 8, 2015

Workgroup Creation script for Exchange UM/Lync

I pumped this really quick because I needed to change the sip URIs of more than 10 workgroups in a row, Lync/Exchange does not allow you to do this without deleting and recreating the workgroup from scratch, so, Powershell to the rescue.  Obviously you would need to edit this to fit your organization and this script is in no way automated, but should be a good direction to get you started.  DO NOT use this script as is, unless of course you work at the same company as I do!

 #Read-Host  
 $Location = "VisatLaMesa";  
 $displayName = "Vista La Mesa";  
 $vmUser= "sip:" + "VistaLaMesaVM@headstart.admin";  
 $displayNumber = "4032"  
   
 $prompt = " ";  
 $promptOffHours = "Thank you for calling A K A Head Starts " + $displayName + " location, our normal business hours are 8 A M to 4 30 P M, please stay on the line if you would like to leave a message.";  
 $promptHoliday = "Thank you for calling A K A Head Starts " + $displayName + " location, our normal business hours are 8 A M to 4 30 P M, please stay on the line if you would like to leave a message.";  
   
 $lineUri = "TEL:" + $displayNumber;  
 $uri = "sip:" + $Location + "RG@headstart.admin";  
 $displayNameFull = $displayName + " Reception RG";  
 $qname = $displayName + " Reception";  
 $qid = (Get-CsRgsQueue -Name $qname).Identity;  
   
 $promptWM = New-CsRgsPrompt -TextToSpeechPrompt $prompt;  
 $promptBusWM = New-CsRgsPrompt -TextToSpeechPrompt $promptOffHours;  
 $promptHolWM = New-CsRgsPrompt -TextToSpeechPrompt $promptHoliday;  
 $busHours = Get-CsRgsHoursOfBusiness;  
   
 $actionWM = New-CsRgsCallAction -Prompt $promptWM -Action TransferToQueue -QueueID $qid  
 #$actionBusWM = New-CsRgsCallAction -Prompt $promptBusWM -Action TransferToVoiceMailUri -Uri $vmUser  
 #$actionHolWM = New-CsRgsCallAction -Prompt $promptHolWM -Action TransferToVoiceMailUri -Uri $vmUser  
   
 $actionBusWM = New-CsRgsCallAction -Prompt $promptBusWM -Action Terminate  
 $actionHolWM = New-CsRgsCallAction -Prompt $promptHolWM -Action Terminate  
   
 $serviceId="service:"+(Get-CSService | ?{$_.Applications -like "*RGS*"}).ServiceId;  
 $workflowHG = New-CsRgsWorkflow -Parent $serviceId -Name $displayNameFull -PrimaryUri $uri -LineUri $lineUri -DisplayNumber $displayNumber -Active $true -DefaultAction $actionWM -EnabledForFederation $true -NonBusinessHoursAction $actionBusWM -HolidayAction $actionHolWM -BusinessHoursID $busHours.Identity  
   

No comments:

Post a Comment