Skip to content

Instantly share code, notes, and snippets.

@bklockwood
Last active January 23, 2016 10:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bklockwood/a13011f12af6cd452c52 to your computer and use it in GitHub Desktop.
Save bklockwood/a13011f12af6cd452c52 to your computer and use it in GitHub Desktop.
function test-remoteicm {
[CmdletBinding()]
Param ()
$true
write-output "hello"
}
@bklockwood
Copy link
Author

I run the above function (which is in a Powershell module called "pswu") from a win8.1 or win10 machine thusly:

PS> icm t7 {import-module pswu;test-remoteicm}

PS> icm t7 {import-module pswu;test-remoteicm;$null}
True
hello

PS> icm t7 {$null;import-module pswu;test-remoteicm}
True
hello

PS> 

There's no output on the local machine without a $null sent in the invoke-command scriptblock. Why?

The same invoke-command experiment will work fine if the target is a Win10, Win2012r2, or Win8.1 system.

@bklockwood
Copy link
Author

Finally I have found a workaround for this:

PS> icm t7 {import-module pswu; $output = test-remoteicm; $output}
True
hello

PS> 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment