2013-04-25 27 views
0

基本上我想這樣做: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

在此先感謝您的幫助

回答

0

是的,你需要安裝在遠程機器上,作爲調用命令將運行在遠程機器上的commond。如果您使用的是Powershell v3,則無需手動導入,因爲PSV3可以自動導入模塊,但是如果您使用的是powershell-v2,則需要導入-scriptblock {ipmo path\to\module}

+0

感謝您的快速回答! – 2013-04-25 08:09:32