Expand-Archive (PowerShell 5+)

Extract files from an archive (zipped) file.

Syntax
      Expand-Archive [-Path] String [-DestinationPath] String [-Force]
            [-Confirm] [-WhatIf] [CommonParameters]

      Expand-Archive [-DestinationPath] String -LiteralPath String [-Force]
            [-Confirm] [-WhatIf] [CommonParameters]

key
   -DestinationPath String
       The path to the folder in which you want to save the extracted files.

   -LiteralPath String[]
       The path to an archive file..
       Unlike the -Path parameter, the value of -LiteralPath is used exactly as it is typed.
       No characters are interpreted as wildcards. If the path includes escape characters,
       enclose each escape character in single quotation marks, to instruct PowerShell not to
       interpret any characters as escape sequences.

   -Path String[]
       The path to the archive file.

   -Force
       Force the extraction of files from an archive file.

   -Confirm
       Prompt for confirmation before executing the command.

   -WhatIf
       Describe what would happen if you executed the command without actually executing the command.

Examples

Extract the contents of an archive:

PS C:\> Expand-Archive -LiteralPath C:\output\new.Zip -DestinationPath C:\Restored

Display the folder in Windows Explorer:

PS C:\> explorer /select,'C:\output\'

Extract the contents of an archive in the current folder:

PS C:\> Expand-Archive -Path new.Zip -DestinationPath C:\Restored

Extract the contents of all zip files in the current folder:

PS C:\downloads\> Get-ChildItem -Recurse -Filter *.zip |
ForEach-Object {Expand-Archive -Path $_. -Force}

“You can always come back, but you can’t come back all the way” ~ Bob Dylan (Mississippi)

Related PowerShell Cmdlets

Compress-Archive - Create a new archive/zipped file.


 
Copyright © 1999-2024 SS64.com
Some rights reserved