문제

basically I want to do this:

foreach ($SERVER_NAME in $SERVER_NAME_LIST)
{

$SESSION = New-PSSession -ComputerName $SERVER_NAME -Credential $CRED
Invoke-Command -Session $SESSION -ScriptBlock 
{   
    Write-Zip -Path $PATH -OutputPath test.zip -IncludeEmptyDirectories
}
}

I get this error:

The term 'Write-Zip' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Do I really have to install the extension on everey remote maschine and invoke the import module every time?

Thanks in advance for your help

도움이 되었습니까?

해결책

yes, you need to install on each remote machine, as the invoke-command will run the commond on the remote machine. If you are using Powershell v3, you do not need to import manually, as PSV3 could import module automatically, but if you are using powershell-v2, you need to import in the -scriptblock {ipmo path\to\module}

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top