简体   繁体   中英

Zip files remotly using the Powershell extension PSCX

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}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM