Created
August 22, 2018 04:46
-
-
Save GeoffWilliams/8c3d463867d8234b0e2b979c6bd626df to your computer and use it in GitHub Desktop.
Unzip a file using powershell, overwriting any existing files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-Type -AssemblyName System.IO.Compression.FileSystem | |
$zipFile = [System.IO.Compression.ZipFile]::openread("c:\Vagrant\download_and_do\spec\mock\test.zip") | |
foreach ($zipFileEntry in $zipFile.Entries) { | |
$pwd = (Get-Item -Path ".\" -Verbose).FullName | |
$outputFile = [io.path]::combine($pwd, $zipFileEntry.FullName) | |
$dir = ([io.fileinfo]$outputFile).DirectoryName | |
if (-not(Test-Path -type Container -path $dir)) { | |
mkdir $dir | |
} | |
if ($zipFileEntry.Name -ne "") { | |
[System.IO.Compression.ZipFileExtensions]::ExtractToFile($zipFileEntry, $outputFile, $true) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment