Forum Discussion

JRE77's avatar
JRE77
Copper Contributor
Apr 19, 2021

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.

Resources