Azure Automate: Powershell for skype for business does not give any output back to the runbook

Jurgen Verhelst 326 Reputation points
2021-02-20T08:59:18.87+00:00

Hi Guys,

I created a script to configure Teams Voice for a user. The scripts does configure the user ok. But it is not getting the normal output back

Setup
Added the skype online connector to runbook modules by uploading the zip file
created a powershell runbook with the script below
ran the scrips but no output is returned

I assume because skype cmdlets run in a remote pssession

Is there any to grab the output?

Script:

# Connect to Teams
$session = New-CsOnlineSession -Credential $cred -Verbose
Import-PSSession $session -AllowClobber | Out-Null

# Set Phone Number and Routing Policy to user
Set-CsUser -Identity $Identity -OnPremLineURI tel:+$PhoneNumber -EnterpriseVoiceEnabled $true -HostedVoiceMail $false | Write-Output
Grant-CsOnlineVoiceRoutingPolicy $Identity -PolicyName "Worldwide" | Write-Output

# Close Session
Get-PSSession | Remove-PSSession | Out-Null
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,160 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. tbgangav-MSFT 10,406 Reputation points
    2021-02-25T08:22:07.043+00:00

    Hi anonymous user,

    As per this and this documents and as shown in below screenshots, Set-CsUser cmdlet doesn't return any output and Grant-CsOnlineVoiceRoutingPolicy cmdlet should return system object output.

    71113-image.png
    71131-image.png

    I don't have an environment to test out SkypeForBusiness module cmdlets but see if any of the below options resolves the issue.

    1. Try sending the output of Grant-CsOnlineVoiceRoutingPolicy command to a variable and then write the output after coming out of the session

    $session = New-CsOnlineSession -Credential $cred -Verbose
    Import-PSSession $session -AllowClobber | Out-Null

    Set-CsUser -Identity $Identity -OnPremLineURI +$PhoneNumber -EnterpriseVoiceEnabled $true -HostedVoiceMail $false
    $Output = Grant-CsOnlineVoiceRoutingPolicy $Identity -PolicyName "Worldwide"

    Get-PSSession | Remove-PSSession | Out-Null
    Write-Output $Output

    1. Try sending the output of Grant-CsOnlineVoiceRoutingPolicy command to a file in temp location and then get the file's content and write the output after coming out of the session

    $session = New-CsOnlineSession -Credential $cred -Verbose
    Import-PSSession $session -AllowClobber | Out-Null

    Set-CsUser -Identity $Identity -OnPremLineURI +$PhoneNumber -EnterpriseVoiceEnabled $true -HostedVoiceMail $false
    $Output = Grant-CsOnlineVoiceRoutingPolicy $Identity -PolicyName "Worldwide"
    $Output | Out-File -FilePath ($Env:temp+"/OutputFile.txt")

    Get-PSSession | Remove-PSSession | Out-Null

    $OutputContent = Get-Content -Path ($Env:temp+"/OutputFile.txt")
    Write-Output $OutputContent

    0 comments No comments