Statement separator within scriptblock

%3CLINGO-SUB%20id%3D%22lingo-sub-2278416%22%20slang%3D%22en-US%22%3EStatement%20separator%20within%20scriptblock%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2278416%22%20slang%3D%22en-US%22%3E%3CDIV%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22public-DraftStyleDefault-block%20public-DraftStyleDefault-ltr%22%3E%3CSPAN%3ERunning%20Exchange%202013%20CU23.%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22public-DraftStyleDefault-block%20public-DraftStyleDefault-ltr%22%3E%3CSPAN%3EI%20created%20a%20session%20to%20Exchange%202013%20and%20saved%20it%20as%20a%20variable.%20After%20running%20the%20following%20command...%3A%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3EInvoke-Command%20-Session%20%24SessionVariable%20-ScriptBlock%20%7BGet-RemoteMailbox%20-Identity%20UserName%20%3B%20Get-User%20-Identity%20UserName%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%20class%3D%22public-DraftStyleDefault-block%20public-DraftStyleDefault-ltr%22%3E...I%20get%20the%20following%20error%3A%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3EThe%20syntax%20is%20not%20supported%20by%20this%20runspace.%20This%20can%20occur%20if%20the%20runspace%20is%20in%20no-language%20mode.%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20I%20split-up%20the%20single%20command%20into%20two%20separate%20statements...%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3EInvoke-Command%20-Session%20%24SessionVariable%20-ScriptBlock%20%7BGet-RemoteMailbox%20-Identity%20UserName%7D%0AInvoke-Command%20-Session%20%24SessionVariable%20-ScriptBlock%20%7BGet-User%20-Identity%20UserName%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E...it%20completes%20successfully.%3C%2FP%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22public-DraftStyleDefault-block%20public-DraftStyleDefault-ltr%22%3E%3CSPAN%3EAnybody%20else%20having%20this%20issue%3F%20This%20only%20happened%20within%20that%20past%20few%20days%20and%20I%20can't%20think%20of%20what's%20causing%20the%20issue.%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2278416%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3E2013%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExchange%20Server%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2281658%22%20slang%3D%22en-US%22%3ERe%3A%20Statement%20separator%20within%20scriptblock%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2281658%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F924361%22%20target%3D%22_blank%22%3E%40MichaelHogendoorn_CP%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETake%20a%20look%20at%20%22Known%20Issues%22%20section%20in%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fexchange-team-blog%2Freleased-april-2021-exchange-server-security-updates%2Fba-p%2F2254617%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fexchange-team-blog%2Freleased-april-2021-exchange-server-security-updates%2Fba-p%2F2254617%3C%2FA%3E.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%22%3CEM%3EAfter%20application%20of%20the%20Exchange%20Server%20April%20security%20update%20CMDlets%20executed%20against%20the%20Exchange%20Management%20Console%20using%20an%20invoked%20runspace%20might%20fail%20with%20the%20following%20error%20message%3A%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3EThe%20syntax%20is%20not%20supported%20by%20this%20runspace.%20This%20can%20occur%20if%20the%20runspace%20is%20in%20no-language%20mode.%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3EThis%20behavior%20is%20expected%3B%20please%20change%20any%20code%20using%20.AddScript()%20to%20use%20.AddCommand()%20for%20continued%20compatibility.%3C%2FEM%3E%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20just%20an%20amateur%20Powershell%20scripter%2C%20so%20I%20have%20no%20idea%20how%20to%20use%20.AddScript()%20and%20.AddCommand()%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2281184%22%20slang%3D%22en-US%22%3ERe%3A%20Statement%20separator%20within%20scriptblock%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2281184%22%20slang%3D%22en-US%22%3EWe%20have%20the%20same%20behavior%20JRE77.%20Did%20you%20find%20a%20solution%20yet%3F%3C%2FLINGO-BODY%3E
Occasional Contributor
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.
2 Replies
We have the same behavior JRE77. Did you find a solution yet?

@MichaelHogendoorn_CP 

Take a look at "Known Issues" section in https://techcommunity.microsoft.com/t5/exchange-team-blog/released-april-2021-exchange-server-securi....

 

"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()