I'm attempting to use PsExec to run Expand-Archive on a remote computer, extracting to a folder inside Program Files, but Expand-Archive keeps returning the error:
Expand-Archive : A positional parameter cannot be found that accepts argument 'Files\Folder'
I take this to mean that Expand-Archive gets to the space in "Program Files" and thinks one argument is done and starts trying to interpret the next.
I have used the following variants of the command, all with the same outcome:
Double-quotes around entire Powershell portion, using %programfiles% environment variable:
.\PsExec.exe \\computername /s cmd /c "C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -command expand-archive c:\temp\bc.zip -destinationpath %programfiles%\Folder"
Single-quotes just around the destination folder path, using %programfiles% environment variable:
.\PsExec.exe \\computername /s cmd /c C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -command expand-archive c:\temp\bc.zip -destinationpath '%programfiles%\Folder'
Double-quotes just around the destination folder path, using %programfiles% environment variable:
.\PsExec.exe \\computername /s cmd /c C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -command expand-archive c:\temp\bc.zip -destinationpath "%programfiles%\Folder"
No quotes, using %programfiles% environment variable:
.\PsExec.exe \\computername /s cmd /c C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -command expand-archive c:\temp\bc.zip -destinationpath %programfiles%\Folder
Double-quotes around fully typed folder path:
.\PsExec.exe \\computername /s cmd /c C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -command expand-archive c:\temp\bc.zip -destinationpath "C:\Program Files\Folder"