Microsoft.PowerShell.Archive icon indicating copy to clipboard operation
Microsoft.PowerShell.Archive copied to clipboard

compress-archive doesn't create ZIP file when called via Invoke-Command with -AsJob specified

Open graberman opened this issue 4 years ago • 0 comments

compress-archive does not create ZIP file when called via Invoke-Command with the -AsJob parameter specified. see examples below.

#this works fine, of course compress-archive -path "C:\foo" -destinationPath "C:\bar\my.zip" -force

#this works fine, too Start-Job -name "createZIP" -ScriptBlock { compress-archive -path "C:\foo" -destinationPath "C:\bar\my.zip" -force }

#Invoke-Command - this also works fine $PSSession = New-PSSession -ComputerName $servername Invoke-Command -session $PSSession -ScriptBlock { compress-archive -path "C:\foo" -destinationPath "C:\bar\my.zip" -force }

#Invoke-Command with -AsJob - this doesn't work (no zip is created) $PSSession = New-PSSession -ComputerName $servername Invoke-Command -session $PSSession -ScriptBlock { compress-archive -path "C:\foo" -destinationPath "C:\bar\my.zip" -force } -JobName $servername -AsJob

graberman avatar Jan 29 '21 15:01 graberman