0

基本上我想这样做:

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
}
}

我收到此错误:

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.

我真的必须在everey远程机器上安装扩展并import module每次都调用吗?

在此先感谢您的帮助

4

1 回答 1

0

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}

于 2013-04-25T07:52:22.707 回答