Invoke-command does not return output from modules on v2 targets
I have the following PS module (testme.psm1) saved to a properly-named folder on Win7 (powershell v2) and Win8.1 (powershell v4) machines:
requires -version 2.0
function Test-Output {
[CmdletBinding()]
Param ()
Write-Output "Test-Output SUCCESS"
Write-Verbose "Test-Output VERBOSE SUCCESS"
}
When I test it from a Win10 (PS v5) system, output is as follows:
PS> invoke-command win7 {import-module testme;test-output}
(no output)
PS> invoke-command win7 {import-module testme;test-output -verbose}
(no output)
PS> invoke-command win81 {import-module testme;test-output}
Test-Output SUCCESS
PS> invoke-command win81 {import-module testme;test-output -verbose}
Test-Output SUCCESS
VERBOSE: Test-Output VERBOSE SUCCESS
PS>

2 comments
-
Bryan commented
Here is another example showing the issue: https://gist.github.com/bklockwood/a13011f12af6cd452c52
-
Bryan commented
When I run the same command ( invoke-command win7 {import-module testme;test-output -verbose} ) from the win81 computer, it outputs two lines of text as expected.