If (IsAdmin) { ## Get the path to wireguard.exe If (Test-Path "${Env:ProgramFiles}\Wireguard\wireguard.exe") { $PATH = "${Env:ProgramFiles}\Wireguard\wireguard.exe" } ElseIf (Test-Path "${Env:ProgramFiles}\Wireguard\wireguard.exe") { $PATH = "${Env:ProgramFiles}\Wireguard\wireguard.exe" } Else { $PATH = "" } ## If the path to wireguard.exe is found, update the app If ( -not [string]::IsNullOrEmpty($PATH) ) { Write-Output "Updating Wireguard" Try { Start-Process $PATH -ArgumentList "/update" -Wait } Catch { Write-Error $_.Exception.Message } Write-Output "Finished updating Wireguard" } } Else { Write-Output "You must be a local administrator to update Wireguard" }