How to unzip files in powershell

function Expand-ZIPFile($file, $destination)
{
	$shell = new-object -com shell.application
	$zip = $shell.NameSpace($file)
	foreach($item in $zip.items())
	{
		$shell.Namespace($destination).copyhere($item,16) #16 answers Y to any prompts, eg overwrite
	}
}

#call the function so:

Expand-ZIPFile -file "c:\myfile.zip" -destination "d:\somedestination"

 

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.