remote session invoke-command write-zip

Topics: User Forum
May 6, 2010 at 5:19 AM

I am trying to run the write-zip command in a remote session but get error


The term 'Write-Zip' is not recognized as the name of a cmdlet, function, scrip
t file, or operable program. Check the spelling of the name, or if a path was i
ncluded, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Write-Zip:String) [], CommandNo 
    + FullyQualifiedErrorId : CommandNotFoundException



The script giving the error:

Get-date -uFormat "[%d/%m/%y %T] Begin" | Write-Host $remoteSession = New-PSSession -computerName $remoteServer Get-date -uFormat "[%d/%m/%y %T] Session Open" | Write-Host invoke-command -Session $remoteSession -scriptblock { $filename = "E:\adl_acl.txt" out-file -FilePath $filename -InputObject "some text" Write-Zip $filename -level 9 -removeoriginal | Move-Item \\server\e$\ }

 Remove-PSSession -Session $remoteSession Get-date -uFormat "[%d/%m/%y %T] End" | Write-Host

The PSCX are installed on both the local and remote end. What do i have to do to get this to work? Do I need to export the local session or something?

Feb 25, 2011 at 9:21 PM

I don't see that you imported the PSCX module in the remote session


Add this to the script before you invoke the write-zip cmdlet

invoke-command -session $remoteSession -scriptblock {Import-Module PSCX}

Apr 25, 2013 at 8:31 AM

sorry for refreshing that old stuff here...
I started using PSCX today and I get the same error as shown above doing similar stuff.

$SESSION = New-PSSession -ComputerName $SERVER_NAME -Credential $CRED
Invoke-Command -Session $SESSION -ScriptBlock
Import-Module PSCX
Write-Zip -Path $PATH -OutputPath -IncludeEmptyDirectories

I'll have to zip files remotly on different maschines in different domains... so acutally my question is:

Do I have to install the PSCX extension on the remote maschine??
May 17, 2013 at 4:44 PM
Yes PSCX must be installed on the remote machine.