Created
November 10, 2012 23:38
-
-
Save kyle-herzog/4052988 to your computer and use it in GitHub Desktop.
Powershell script to expand archive files using Windows's shell.
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
function Expand-Item | |
{ | |
param | |
( | |
[Parameter(Mandatory=$true)] [string] $zipFile, | |
[Parameter(Mandatory=$true)] [string] $destinationDirectory | |
) | |
if (!(Test-Path -Path $zipFile -PathType Leaf)) | |
{ | |
throw ("Specified zipFile is invalid: " + $zipFile) | |
} | |
if (!(Test-Path -Path $destinationDirectory -PathType Container)) | |
{ | |
New-Item $destinationDirectory -ItemType Directory | Out-Null | |
} | |
$shell_app = new-object -com shell.application | |
$zip_file = $shell_app.namespace($zipFile) | |
$destination = $shell_app.namespace($destinationDirectory) | |
$destination.Copyhere($zip_file.items(), 0x14) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment