Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use PowerShell `Expand-Archive` upon a zip file with no extension

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?

like image 260
Eugen-Andrei Coliban Avatar asked Oct 09 '18 16:10

Eugen-Andrei Coliban


People also ask

How do I unzip a ZIP file in PowerShell?

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.

What is the extension of ZIP file?

ZIP files generally use the file extensions .zip or .ZIP and the MIME media type application/zip .

What PowerShell command can be used to extract and compress archives right from the command line?

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.


1 Answers

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).

like image 118
Maximilian Burszley Avatar answered Sep 28 '22 02:09

Maximilian Burszley