Zip文件remotly使用PowerShell的扩展PSCX
问题描述:
基本上我想这样做:Zip文件remotly使用PowerShell的扩展PSCX
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远程maschine的延伸和每次调用import module
?
在此先感谢您的帮助
答
是的,你需要安装在远程机器上,作为调用命令将运行在远程机器上的commond。如果您使用的是Powershell v3,则无需手动导入,因为PSV3可以自动导入模块,但是如果您使用的是powershell-v2,则需要导入-scriptblock {ipmo path\to\module}
感谢您的快速回答! – 2013-04-25 08:09:32