I'm working upon a PowerShell script, where I have to extract the content out of a .zip
archive which extension is removed, so, archive's name is let's say not test.zip
but just test
, and it is compressed as a .zip
archive.
I'm trying to use for this purpose the PowerShell cmdlet Expand-Archive
like shown below :
Expand-Archive -LiteralPath "Path to the archive" -DestinationPath "Extraction Path"
But, it doesn't seem to work, is there a possibility of extracting this archive's content with powershell, or it would be better to use a work around like 7zip command line tools, or something similar?
To unzip a file using PowerShell, you can utilize the “Expand-Archive” command. The Expand-Archive command unzips or extracts the content of a zipped or archived file to its destination folder.
ZIP files generally use the file extensions .zip or .ZIP and the MIME media type application/zip .
What's the PowerShell commandlet you can use to extract and compress archives right from the commandline? Compress-Archive; The Compress-Archive commandlet in PowerShell can help you work with Archives from the command line.
The Expand-Archive
cmdlet is designed to explicitly work with a path that has a .zip
extension. You can work around this by either creating a copy of your archive with a proper extension using Copy-Item
or renaming the archive to have an extension with Rename-Item
(using Move-Item
may be more desirable if the archive with extension already exists and you want to overwrite it; Rename-Item
is not capable of overwriting).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With