40 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PowerShell
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PowerShell
		
	
	
	
	
	
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls12
 | 
						|
 | 
						|
$PackagesPath = 'C:\Packages'
 | 
						|
$DestinationPath = 'C:\Program Files\iperf3'
 | 
						|
 | 
						|
$InstallerUrl = 'https://github.com/ar51an/iperf3-win-builds/releases/download/3.17.1/iperf-3.17.1-win64.zip'
 | 
						|
 | 
						|
$ArchivePath = Join-Path -Path $PackagesPath -ChildPath ($InstallerUrl | Select-String -Pattern "(iperf-(?:\d\.?)+-win64\.zip)").Matches.Value
 | 
						|
 | 
						|
# Exit if the application is already installed
 | 
						|
if (Test-Path $DestinationPath) { Write-Host 'iPerf3 is already installed.'; exit }
 | 
						|
 | 
						|
# Prep
 | 
						|
 | 
						|
# Create the $PackagesPath directory if it doesn't already exist
 | 
						|
if (-not (Test-Path -PathType Container $PackagesPath)) { New-Item -ItemType Directory -Path $PackagesPath | Out-Null }
 | 
						|
 | 
						|
# Download
 | 
						|
 | 
						|
Write-Host "Downloading application..."
 | 
						|
# Use Legacy WebClient for compatibility
 | 
						|
(New-Object Net.WebClient).DownloadFile($InstallerUrl, $ArchivePath)
 | 
						|
 | 
						|
# Extract
 | 
						|
 | 
						|
Write-Host "Extracting application..."
 | 
						|
Expand-Archive -Path $ArchivePath -DestinationPath $DestinationPath -Force
 | 
						|
Write-Host "Application extracted to $DestinationPath"
 | 
						|
 | 
						|
# Install
 | 
						|
 | 
						|
Write-Host "Installing application..."
 | 
						|
 | 
						|
# Add the DestinationPath to Path system environment variable
 | 
						|
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";$DestinationPath\", [System.EnvironmentVariableTarget]::Machine)
 | 
						|
 | 
						|
# Clean up
 | 
						|
 | 
						|
Write-Host "Removing package download from '$ArchivePath'"
 | 
						|
Remove-Item -Path $ArchivePath -Force |