powershell download zip file from url code example
Example 1: powershell download a file from url
$Link = "https://www.7-zip.org/a/7z1900-x64.msi"
$WebClient = New-Object System.Net.WebClient
$WebClient.DownloadFile("$Link","$env:USERPROFILE\Downloads\7zip1900.msi");
Example 2: browse for zip file powershell
function BrowseForFile($initialFile="")
{
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
$openFileDialog = New-Object System.Windows.Forms.OpenFileDialog
$openFileDialog.Title = "Choose a ZIP file"
$openFileDialog.initialDirectory = $PSScriptRoot
$openFileDialog.filter = "zip folder (*.zip)| *.zip"
if ($openFileDialog.ShowDialog() -eq "OK")
{
return $openFileDialog.FileName
} else {
return $initialFile
}
}
$window.FindName("ZipFile").Text = $PSScriptRoot + "\_SampleFiles\Content.zip"
$BrowseForZIPFileButton = $window.FindName("BrowseForZIPFile")
$BrowseForZIPFileButton.Add_Click({
$currentFile = $window.FindName("ZipFile").Text
$window.FindName("ZipFile").Text = BrowseForFile($currentFile)
})