PowerShell Genie

Expand-Archive

Use Expand-Archive to extract the contents of a zip archive to a folder.

Command 1 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn — PowerShell module reference

Syntax

1PS> Expand-Archive [-Path] <String> [[-DestinationPath] <string>] [-Force] [-PassThru] [<CommonParameters>]
See the command anatomy

Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.

Expand-Archive [-Path] <String> [[-DestinationPath] <string>] [-Force] [-PassThru] [<CommonParameters>]
  1. Stage 1Expand-Archive-Path -DestinationPath -Force -PassThru

    Try it

    Windows PowerShell

    PowerShell example · browser support is limited.

    Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.

    Interactive simulation · fictional data

    Examples

    Expand-Archive -Path 'C:\Temp\scripts.zip'

    1PS> Expand-Archive -Path 'C:\Temp\scripts.zip' -DestinationPath 'C:\Temp\extracted'
    Show reference output

    Sample output · fictional data, shaped like the real thing

        Directory: C:\Temp\extracted
    
    
    Mode                 LastWriteTime         Length Name
    ----                 -------------         ------ ----
    -a----         10/9/2026   2:22 PM           2418 Backup-Files.ps1
    -a----         10/9/2026   2:22 PM           1876 Deploy-App.ps1
    -a----         10/9/2026   2:22 PM            954 New-UserReport.ps1

    Expand-Archive -Path 'C:\Temp\scripts.zip' (2)

    1PS> Expand-Archive -Path 'C:\Temp\scripts.zip' -DestinationPath 'C:\Temp\extracted' -Force
    Show reference output

    Sample output · fictional data, shaped like the real thing

        Directory: C:\Temp\extracted
    
    
    Mode                 LastWriteTime         Length Name
    ----                 -------------         ------ ----
    d-----         10/9/2026   2:23 PM                Modules
    -a----         10/9/2026   2:23 PM           2418 Backup-Files.ps1
    -a----         10/9/2026   2:23 PM           1876 Deploy-App.ps1

    Parameters

    Parameter definitions:

    • -Path
    • -DestinationPath
    • -Force
    • -PassThru

    PowerShell module reference on Microsoft Learn

    Practical use and troubleshooting

    Practical scenario: Use Expand-Archive when you need to extract the contents of a zip archive to a folder. Review syntax and sample output, then try an example in the browser lab. Start with one identified target and inspect the returned values before extending the operation to a list. Keep the identity in your report so you can trace each result back to the object or path that produced it.

    Common error and fix: Existing destination files can prevent extraction. Extract into a new empty directory or use -Force only when replacing those files is intended; inspect the resulting directory afterwards. In an unattended script, capture this failure with its original error record and record which target failed. An empty result and an unsuccessful query must remain distinguishable in the final report.

    See also: Compress-Archive. Compress-Archive writes a ZIP archive; Expand-Archive extracts one. Confirm the source set before compression and the destination before extraction. Read the linked command before substituting it; similar names do not imply identical inputs or output.

    Expand-Archive reference on Microsoft Learn

    Recap

    Expand-Archive Use Expand-Archive to extract the contents of a zip archive to a folder.

    Next: Compress-Archive
    Genie guideExpand-Archive

    Use Expand-Archive to extract the contents of a zip archive to a folder. The console below is pre-loaded — run it, then change a value and run it again.