Skip to content

Instantly share code, notes, and snippets.

@kyle-herzog
Created November 10, 2012 23:38
Show Gist options
  • Save kyle-herzog/4052988 to your computer and use it in GitHub Desktop.
Save kyle-herzog/4052988 to your computer and use it in GitHub Desktop.
Powershell script to expand archive files using Windows's shell.
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