Skip to content

Instantly share code, notes, and snippets.

@alex-berezan
Created January 20, 2016 04:39
Show Gist options
  • Save alex-berezan/82af20ca247edb514763 to your computer and use it in GitHub Desktop.
Save alex-berezan/82af20ca247edb514763 to your computer and use it in GitHub Desktop.
quick sample for unzipping archive via powershell 2.0
function Unzip-Archive([string] $ZipFileName, [string] $DestinationDirectory)
{
if(-not [System.IO.Directory]::Exists($DestinationDirectory))
{
[System.IO.Directory]::CreateDirectory($DestinationDirectory) | Out-Null
}
$shell_app = New-Object -com shell.application
$zip_file = $shell_app.namespace($ZipFileName)
$destination = $shell_app.namespace($DestinationDirectory)
$Flag_OverrideExisting_HideDialog = 0x14
$destination.Copyhere($zip_file.items(), $Flag_OverrideExisting_HideDialog)
}
Unzip-Archive -ZipFileName "C:\Users\Aleksey\Downloads\ziptest\zipped.zip" `
-DestinationDirectory "C:\Users\Aleksey\Downloads\ziptest\unzipped"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment