7Zip Powershell not working

Viewed 8479

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?

1 Answers
Related