Forum Discussion
JRE77
Apr 19, 2021Copper Contributor
Statement separator within scriptblock
Running Exchange 2013 CU23.
I created a session to Exchange 2013 and saved it as a variable. After running the following command...:
Invoke-Command -Session $SessionVariable -ScriptBlock {Get-RemoteMailbox -Identity UserName ; Get-User -Identity UserName}
...I get the following error:
The syntax is not supported by this runspace. This can occur if the runspace is in no-language mode.
If I split-up the single command into two separate statements...:
Invoke-Command -Session $SessionVariable -ScriptBlock {Get-RemoteMailbox -Identity UserName}
Invoke-Command -Session $SessionVariable -ScriptBlock {Get-User -Identity UserName}
...it completes successfully.
Anybody else having this issue? This only happened within that past few days and I can't think of what's causing the issue.
- MichaelHogendoorn_CPCopper ContributorWe have the same behavior JRE77. Did you find a solution yet?
- JRE77Copper Contributor
Take a look at "Known Issues" section in https://techcommunity.microsoft.com/t5/exchange-team-blog/released-april-2021-exchange-server-security-updates/ba-p/2254617.
"After application of the Exchange Server April security update CMDlets executed against the Exchange Management Console using an invoked runspace might fail with the following error message:
The syntax is not supported by this runspace. This can occur if the runspace is in no-language mode.
This behavior is expected; please change any code using .AddScript() to use .AddCommand() for continued compatibility."I'm just an amateur Powershell scripter, so I have no idea how to use .AddScript() and .AddCommand()