Files
management-scripts/Install-Wireguard.ps1
T

28 lines
1.3 KiB
PowerShell
Raw Normal View History

2020-12-22 11:02:15 -05:00
## Create a desktop shortcut for WireGuard?
2020-12-22 13:23:44 -05:00
$CreateDesktopShortcut = $true
2020-12-22 11:02:15 -05:00
2020-11-19 17:50:42 -05:00
## Make sure we have an administrative token
If ( IsAdmin )
{
If ( Is64bit ) { $URL = 'https://download.wireguard.com/windows-client/wireguard-amd64-latest.msi' }
Else { $URL = 'https://download.wireguard.com/windows-client/wireguard-x86-latest.msi' }
2020-11-19 17:50:42 -05:00
## Install package
$Installer = Download-File -URL $URL
Try { Start-Process "msiexec.exe" -ArgumentList "/i ${Installer} /qn /norestart DO_NOT_LAUNCH=1" -Wait -ErrorAction Stop }
Catch { LogErr $_.Exception.Message ; Exit }
## Delete installer
Try { If ( Test-Path $Installer ) { Remove-Item $Installer -Force } }
Catch { LogErr $_.Exception.Message }
## Install manager service
Try { Start-Process "${Env:ProgramFiles}\WireGuard\wireguard.exe" -ArgumentList '/installmanagerservice' -Wait -ErrorAction SilentlyContinue }
Catch { LogErr $_.Exception.Message }
2020-12-03 18:16:55 -05:00
## Create shortcut on Public desktop
2020-12-22 11:02:15 -05:00
If ( $CreateDesktopShortcut ) {
2020-12-22 13:23:44 -05:00
Create-Shortcut -Path "${Env:Public}\Desktop\WireGuard VPN.LNK" -TargetPath "${Env:ProgramFiles}\WireGuard\wireguard.exe" -Description "WireGuard: Fast, Modern, Secure VPN Tunnel"
2020-12-22 11:02:15 -05:00
}
2020-11-19 17:50:42 -05:00
}
Else { LogMsg "Must be an administrator to install WireGuard" }