An archive or zip file is a package that contains multiple files compressed in a single file. The “Expand-Archive” cmdlet extracts or expands the archive files to a specified location or folder in PowerShell. When files are compressed or archived, they can be shared with friends via email. Moreover, the virus can not affect the archived files.
This tutorial will cover the details related to the “Expand-Archive” cmdlet.
How to Utilize the PowerShell’s Expand-Archive Cmdlet?
As described earlier, to extract the content of a particular archive file into a desired location or folder, the “Expand-Archive” cmdlet can be used. Overview the below-given examples to learn the working of the “Expand-Archive” cmdlet.
Example 1: Use the Cmdlet “Expand-Archive” to Extract the Archive’s Content
Use the provided cmdlet to expand an archive in PowerShell:
According to the above-stated code:
-
- Initially, specify the “Expand-Archive” cmdlet.
- Then, mention the “-LiteralPath” parameter and assign it to the zip file.
- Lastly, add the “-DestinationPath” parameter and assign the destination path.
Example 2: Overwrite an Existing Zip File Using the “Expand-Service” Cmdlet in PowerShell
To overwrite the already extracted content in a directory, use the “-Force” parameter:
That’s all! We have compiled different examples related to the “Expand-Archive” cmdlet in PowerShell.
Conclusion
The “Expand-Archive” cmdlet in PowerShell is used for extracting or expanding the contents of a file into a specific location. This post has covered the details and working of the “Expand-Archive” cmdlet in PowerShell.