I'm having trouble getting a .7z
file to extract via Powershell.
My PowerShell function looks like this:
function unzip($file, $destination)
{
& 'C:\Program Files\7-Zip\7z.exe' x -y $file -o"$destination";
}
I get this error:
7z.exe :
At restoreQA.ps1:26 char:5
+ & 'C:\Program Files\7-Zip\7z.exe' x -y $file -o"$destination";
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Command Line Error:
Too short switch:
-o
There seems to be some sort of parsing error but I've tried every different combination to get it working.
Any ideas on why this is not working?
You need to put -o in quotes:
& 'C:\Program Files\7-Zip\7z.exe' x -y $file "-o$destination"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With