Search code examples
powershellshellconsolewindowpowershell-5.1

Expand-Archive giving syntax error in PowerShell v5.1 (A parameter cannot be found that matches parameter name 'DestinationPath') , Why?


With an aim of a simple extraction of .zip file with minimum size (20MB) works perfectly fine in PowerShell 7.3.1 Version but not in 5.1, Why?

COMMAND:

Expand-Archive -Path $Path\compressed.zip -DestinationPath $Path\Destination

ERROR:

A parameter cannot be found that matches parameter name 'DestinationPath'

enter image description here

What's the silly mistake I did here, Or it won't work in PowerShell 5.1?

It should work as per the documentation given by Microsoft here Expand Archive in PS 5.1

enter image description here


Solution

  • Adding @Santiago's comment as an Answer here as this has solved my mystery, I wouldn't want one person to miss it and waste their time to solve this issue.

    I've added Microsoft.PowerShell.Archive to use it from the correct library.

    Microsoft.PowerShell.Archive\Expand-Archive -Path $Path\compressed.zip -DestinationPath $Path\Destination