Simple automation script to connect to Sophos VPN without user interaction
Add these to something in your path so you can connect quickly with a single cmdlet. On first run, it will collect details needed for the connectiong.
function Connect-SophosSample([bool] $killExisting = $false) {
$props = Get-VpnAuthDetails "profile-name";
Start-SophosVpnConnection $props.profileName $props.userName $props.securePassword $props.otpKey $killExisting;
}
function Connect-FortiSample([bool] $killExisting = $false) {
$props = Get-VpnAuthDetails "profile-name" $true;
$totp = Get-Totp $props.otpKey;
Write-Host "Unsupported vpn (Forti). Generated TOTP.";
$totp;
}