基本上我想这样做:
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.我真的需要在每个远程机器上安装这个扩展并每次都调用import module吗?
提前感谢您的帮助
发布于 2013-04-25 15:52:23
是的,您需要在每台远程机器上安装,因为invoke-command将在远程机器上运行命令。如果您使用的是Powershell v3,则不需要手动导入,因为PSV3可以自动导入模块,但是如果您使用的是powershell-v2,则需要在-scriptblock {ipmo path\to\module}中导入。
https://stackoverflow.com/questions/16209132
复制相似问题