Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

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

Open
graberman opened this issue Jan 29, 2021 · 0 comments

Comments

@graberman
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants