Expand-Archive (PowerShell 5+)

Extract files from an archive (zipped) file.

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

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

   -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 the extraction of files from an archive file.

       Prompt for confirmation before executing the command.

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


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\> gci -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-2023 SS64.com
Some rights reserved