I have a fairly simple Azure Powershell function that connects to Teams and requests a user by calling Get-CSOnlineUser. It seems that it randomly succeeds or failes with a "GetSteppablePipeline" error.
This is part of the code:
$securePassword = ConvertTo-SecureString -string $adminPassword -AsPlainText -force
$teamsCredential = New-Object System.Management.Automation.PSCredential ($adminName, $securePassword)
Write-Host "Connecting as $adminName"
Connect-MicrosoftTeams -Credential $teamsCredential
Write-Host "Getting user info for $upn"
$user = Get-CSOnlineUser -Identity "$upn" | Select OnlineVoiceRoutingPolicy, OnPremLineUri, EnterpriseVoiceEnabled, OnlineVoicemailPolicy,DisplayName
And this a log of two sequential calls to the function, with first a success result and in the second call it errors:
2022-02-25T08:51:33.265 [Information] Executing 'Functions.GetOnlineVoiceUser' (Reason='This function was programmatically called via the host APIs.', Id=xxxxx)
2022-02-25T08:51:34.077 [Information] INFORMATION: PowerShell HTTP trigger function processed a request.
2022-02-25T08:51:34.078 [Information] INFORMATION: Loading Teams module
2022-02-25T08:51:58.149 [Information] INFORMATION: Loaded Module 'Microsoft.Teams.ConfigAPI.Cmdlets'
2022-02-25T08:51:58.983 [Information] INFORMATION: Connecting to teams
2022-02-25T08:51:58.989 [Information] INFORMATION: Connecting as xxxxxanonymous user
2022-02-25T08:52:00.348 [Information] OUTPUT:
2022-02-25T08:52:03.768 [Information] INFORMATION: Getting user info for AlexW@Piepel .OnMicrosoft.com
2022-02-25T08:52:05.602 [Information] INFORMATION: returning body = {"upn": "*****@Mxxxxx.OnMicrosoft.com", "VoiceRoutingPolicy": "UNRESTRICTED", "LineUri": "", "EnterpriseVoiceEnabled": "True", "VoicemailPolicy": "TranscriptionDisabled", "userDisplayName": "Alex Wilber"}
2022-02-25T08:52:05.602 [Information] OUTPUT: Account Environment Tenant TenantId
2022-02-25T08:52:05.602 [Information] OUTPUT: ------- ----------- ------ --------
2022-02-25T08:52:05.602 [Information] OUTPUT: xxxx@xxxxxx .onmicrosoft.com AzureCloud xxxxxxxxxxxxxxxxxxx
2022-02-25T08:52:05.603 [Information] OUTPUT:
2022-02-25T08:52:05.603 [Information] Executed 'Functions.GetOnlineVoiceUser' (Succeeded, Id=xxxxxxx, Duration=32339ms)
2022-02-25T08:52:18.388 [Information] Executing 'Functions.GetOnlineVoiceUser' (Reason='This function was programmatically called via the host APIs.', Id=xxxxxxx)
2022-02-25T08:52:19.170 [Information] INFORMATION: PowerShell HTTP trigger function processed a request.
2022-02-25T08:52:19.171 [Information] INFORMATION: Loading Teams module
2022-02-25T08:52:45.370 [Information] INFORMATION: Loaded Module 'Microsoft.Teams.ConfigAPI.Cmdlets'
2022-02-25T08:52:45.978 [Information] INFORMATION: Connecting to teams
2022-02-25T08:52:45.978 [Information] INFORMATION: Connecting as xxxxxanonymous user*
2022-02-25T08:52:46.278 [Information] OUTPUT:
2022-02-25T08:52:47.259 [Information] INFORMATION: Getting user info for AlexWanonymous user.OnMicrosoft.com
2022-02-25T08:52:47.854 [Error] EXCEPTION: Exception calling "GetSteppablePipeline" with "1" argument(s): "The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, a script block, or a CommandInfo object."Exception :Type : System.Management.Automation.ParentContainsErrorRecordExceptionMessage : Exception calling "GetSteppablePipeline" with "1" argument(s): "The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, a script block, or a CommandInfo object."HResult : -2146233087CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordExceptionFullyQualifiedErrorId : RuntimeExceptionInvocationInfo :ScriptLineNumber : 67596OffsetInLine : 9HistoryId : -1ScriptName : C:\home\data\ManagedDependencies\2202221459460733933.r\MicrosoftTeams\3.1.1\netcoreapp3.1\exports\ProxyCmdletDefinitions.ps1Line : $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin)PositionMessage : At C:\home\data\ManagedDependencies\2202221459460733933.r\MicrosoftTeams\3.1.1\netcoreapp3.1\exports\ProxyCmdletDefinitions.ps1:67596 char:9+ $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvoc …+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~PSScriptRoot : C:\home\data\ManagedDependencies\2202221459460733933.r\MicrosoftTeams\3.1.1\netcoreapp3.1\exportsPSCommandPath : C:\home\data\ManagedDependencies\2202221459460733933.r\MicrosoftTeams\3.1.1\netcoreapp3.1\exports\ProxyCmdletDefinitions.ps1CommandOrigin : InternalScriptStackTrace : at Get-CsUserPoint<Begin>, C:\home\data\ManagedDependencies\2202221459460733933.r\MicrosoftTeams\3.1.1\netcoreapp3.1\exports\ProxyCmdletDefinitions.ps1: line 67596at Get-CsOnlineUser<Process>, C:\home\data\ManagedDependencies\2202221459460733933.r\MicrosoftTeams\3.1.1\netcoreapp3.1\exports\ProxyCmdletDefinitions.ps1: line 10894at <ScriptBlock>, C:\home\site\wwwroot\GetOnlineVoiceUser\run.ps1: line 32
2022-02-25T08:52:47.905 [Error] Executed 'Functions.GetOnlineVoiceUser' (Failed, Id=4b616058-ac1d-4998-bafe-a005260dc2b2, Duration=29501ms)Result: FailureException: Exception calling "GetSteppablePipeline" with "1" argument(s): "The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, a script block, or a CommandInfo object."Stack: at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)at System.Management.Automation.Runspaces.Pipeline.Invoke()at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)at System.Management.Automation.PowerShell.CoreInvokeHelperTInput,TOutputat System.Management.Automation.PowerShell.CoreInvokeTInput,TOutputat System.Management.Automation.PowerShell.InvokeTat System.Management.Automation.PowerShell.InvokeTat Microsoft.Azure.Functions.PowerShellWorker.PowerShell.PowerShellExtensions.InvokeAndClearCommandsT in /home/vsts/work/1/s/src/PowerShell/PowerShellExtensions.cs:line 45at Microsoft.Azure.Functions.PowerShellWorker.PowerShell.PowerShellManager.InvokeNonOrchestrationFunction(DurableController durableController, IDictionary outputBindings) in /home/vsts/work/1/s/src/PowerShell/PowerShellManager.cs:line 294at Microsoft.Azure.Functions.PowerShellWorker.PowerShell.PowerShellManager.InvokeFunction(AzFunctionInfo functionInfo, Hashtable triggerMetadata, TraceContext traceContext, IList`1 inputData, FunctionInvocationPerformanceStopwatch stopwatch) in /home/vsts/work/1/s/src/PowerShell/PowerShellManager.cs:line 229at Microsoft.Azure.Functions.PowerShellWorker.RequestProcessor.InvokeFunction(AzFunctionInfo functionInfo, PowerShellManager psManager, FunctionInvocationPerformanceStopwatch stopwatch, InvocationRequest invocationRequest) in /home/vsts/work/1/s/src/RequestProcessor.cs:line 334at Microsoft.Azure.Functions.PowerShellWorker.RequestProcessor.ProcessInvocationRequestImpl(StreamingMessage request, AzFunctionInfo functionInfo, PowerShellManager psManager, FunctionInvocationPerformanceStopwatch stopwatch) in /home/vsts/work/1/s/src/RequestProcessor.cs:line 307
Any ideas?