Code snippets : Downloading file from URL in PowerShell


To download file from URL I used following piece of code:

$fileURL = "http://server/file.zip"
$fileName = "C:\Downloads\file.zip"
$webclient = New-Object System.Net.WebClient

Code snippets : Unzip file in PowerShell


Recently I needed to unzip file from PowerShell script. Here is result what I did use to achieve that:

$archiveDir = "C:\Downloads"
$fileZip = $archiveDir + "\file.zip"
$shell=new-object -com shell.application
$zip = $shell.NameSpace($fileZip)
foreach ($item in $zip.items())