Manage Response Groups in Powershell

When managing Response Groups in SKYPE for Business, the tool needed is the Classic “Manage or edit Workflows” Website – very often customers ask if they can control these options by powershell, or even automate some actions.



This is indeed possible, the powershell way may seem a bit wrinkled – but it works. 🙂

I will describe the two most commonly used task – that is changing the PSTN forward location for out of Business Hours, and also changing the prompt (audiofile) and Voicemail

First the Process for changing the Audio File and setting forward to Voicemail – if for example you want change the wording from “You are now being forwarded to VoicemailA” – to “You are being forwarded to VoicemailB”

First of you should identify your Response Groups workflows – we need the Identity string for later.

Run this in Powershell:

get-CsRgsWorkflow | ft Identity,Name -auto


If you want to you can now save the current config to a txt file

get-CsRgsWorkflow service:ApplicationServer:FE1.spinne.local/d546f544-1443-1443-1234 > C:Workflow.txt
In the meantime prepare the new audiofile - keeping requirements in mind:
https://technet.microsoft.com/en-us/library/gg398649(v=ocs.14).aspx
And then load it into a variable as a new CsRgsAudioFile:
$audioFile = Import-CsRgsAudioFile -Identity "service:ApplicationServer:FE1.spinne.local" 
-FileName "Audioprompt.wav" -Content (Get-Content C:Audioprompt.wav -Encoding byte -ReadCount 0)

Now create a new CsRgsPrompt that links to the file.
(Type the text here if you were instead going to use Text To Speech)
$prompt = New-CsRgsPrompt -AudioFilePrompt $audioFile

Now Create a new CsRgsCallAction that is the Action the workflow will take when Outside Business Hours.
 In this case two Actions will occur, play a prompt and then transfer the call to voicemail
$action = New-CsRgsCallAction –prompt $prompt -Action TransferToVoicemailUri -Uri "sip:voicemail@spinne.dk"

Now Read the whole workflow into its own Variable

$workflow = get-csRgsWorkflow “service:ApplicationServer:FE1.spinne.local/d546f544-1443-1443-1234”

Now we can customize the workflow by adding the action defines earlier:
$workflow.NonBusinessHoursAction = $action

And finally write the whole thing back to existing workflow - and thereby owerwrtiting existing config.
Set-CsRgsWorkflow $workflow

So a script doing the whole process in one step would look like this:

$audioFile = Import-CsRgsAudioFile -Identity "service:ApplicationServer:FE1.spinne.local" 
-FileName "Audioprompt.wav" -Content (Get-Content C:Audioprompt.wav -Encoding byte -ReadCount 0)
$prompt = New-CsRgsPrompt -AudioFilePrompt $audioFile
$action = New-CsRgsCallAction –prompt $prompt -Action TransferToVoicemailUri -Uri "sip:voicemail@spinne.dk"
$workflow = get-csRgsWorkflow “service:ApplicationServer:FE1.spinne.local/d546f544-1443-1443-1234”
$workflow.NonBusinessHoursAction = $action
Set-CsRgsWorkflow $workflow


Now you could save different PS1 files named by name of Workflow, or even take it at step further, 
putting the whole thing into Orchestrator and making e.g. Voicemail destination as an variable.
Also worth noting the power of the New-csRGScallaction cmdlet - read more here:
https://technet.microsoft.com/en-us/library/gg398136.aspx

The next example is more simple, but also more commonly used - it simply changes the PSTN number that the
Workflow forwards to when outside business hours.

$action = New-CsRgsCallAction -Action TransferToPSTN -Uri "sip:+4511111111@spinne.dk"
$workflow = get-csRgsWorkflow “service:ApplicationServer:FE1.spinne.local/d546f544-1443-1443-1234”
$workflow.NonBusinessHoursAction = $action
Set-CsRgsWorkflow $workflow

Thats it 🙂

Lastly i wanna point your attention to a brilliant script made available on Technet - making it possible to automatically 
cycle between PSTN forwards, for example if you have a IT hotline where We rotate the on call responsibility weekly between the techies on duty. 
That script can be found here:
https://gallery.technet.microsoft.com/office/Lync-Workflow-off-hours-da661656

As Always Happy SKYPE'ing

Leave a Reply

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