I am attempting to use implicit remoting. We have a jump server in a different data center. I want to run Invoke-Command
implicitly on that jump server to be able to run commands on other servers it can access. I am able to export Invoke-Command
, and import the module with a prefix. The problem I am running into is that it says it cannot convert a string to a scriptblock.
Here is an example:
Invoke-xxxCommand -ComputerName 'whatever-server' -ScriptBlock {
Write-Host $env:COMPUTERNAME
}
I understand I can just use a PSSession to connect to the jump server. I am curious why this does not work.
Here is the error:
Cannot bind parameter 'ScriptBlock'. Cannot convert the "Write-Host $env:COMPUTERNAME" value of type "System.String" to type "System.Management.Automation.ScriptBlock".