Public/Start-PuTTY.ps1
Function Start-PuTTY { <# .Synopsis Starts Putty .Description Starts Putty either locally or by downloading it from the official website .Example Start-Putty Starts Putty .Parameter Online Downloads and starts latest version of PuTTY from the official website .LINK about_functions_advanced .LINK about_CommonParameters #> [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Medium" )] Param ( [switch]$online ) If ($online) { $webclient = New-Object System.Net.WebClient $url = "https://the.earth.li/~sgtatham/putty/latest/x86/putty.exe" $file = "$($env:TEMP)\putty.exe" $webclient.DownloadFile($url, $file) Invoke-Item $file } If (!($online)) { $PuTTY = "C:\Program Files (x86)\PuTTY\putty.exe" $FileExists = Test-Path $PuTTY If ($FileExists -eq "True") { Write-Verbose "Starting PuTTY..." Start-Process $PuTTY } If ($FileExists -ne "True") { Write-Warning "PuTTY not installed locally, running online version!" $webclient = New-Object System.Net.WebClient $url = "https://the.earth.li/~sgtatham/putty/latest/x86/putty.exe" $file = "$($env:TEMP)\putty.exe" $webclient.DownloadFile($url, $file) Invoke-Item $file } } } |