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

こ雲淡風輕ζ 提交于 2020-01-03 10:57:31

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/52725446/can-i-use-powershell-expand-archive-upon-a-zip-file-with-no-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!