Open igpit opened 4 years ago
turns out you just need to set
CacheCredentials=1
in the pbk file
"%AppData%\Microsoft\Network\Connections\Pbk\rasphone.pbk"
@igpit are you manually going into the pbk file and adding the cachecredentials=1 ? Or did you include that in your script? If so , how?
I wrote a script to mod this settings and others. Here it is for anyone else. Hope it helps.
#Requires -RunAsAdministrator
#Requires -Module PsIni
$vpns = (Get-VpnConnection | Where-Object { $_.ServerAddress -match "XXX.XXX.XXX.(XXX|YYY)" })
if ($vpns.Count -eq 0) {
Write-Warning "NO MATCHING VPNS FOUND"
}
Import-Module PsIni -Scope AllUsers
$fileName = "$($env:APPDATA)\Microsoft\Network\Connections\Pbk\rasphone.pbk"
$ini = Get-IniContent $fileName
$settings = New-Object System.Collections.ArrayList
foreach ($vpn in $vpns) {
$vpnName = $vpn.Name
Write-Host "MODIFYING VPN: [$vpnName]" -ForegroundColor Yellow
$settings.Add((ChangeIniSetting -sectionName $vpnName -section $ini[$vpnName] -keyName "AlwaysOnCapable" -value 1)) | Out-Null
$settings.Add((ChangeIniSetting -sectionName $vpnName -section $ini[$vpnName] -keyName "IpInterfaceMetric" -value 2)) | Out-Null
$settings.Add((ChangeIniSetting -sectionName $vpnName -section $ini[$vpnName] -keyName "IdleDisconnectSeconds" -value ([Timespan]::FromHours(4).TotalSeconds))) | Out-Null
$settings.Add((ChangeIniSetting -sectionName $vpnName -section $ini[$vpnName] -keyName "CacheCredentials" -value 1)) | Out-Null
}
$settings | Format-Table
if ($settings | Where-Object { $_.Changed } ) {
Write-Host "Saving $fileName" -ForegroundColor Yellow
$ini | Out-IniFile -FilePath "$fileName" -Force -Encoding ASCII
} else {
Write-Host "No settings changed, skipping save." -ForegroundColor Yellow
}
using Set-VpnConnectionUsernamePassword username and password can be added to a created VPN connection fine. but trying to connect it clicking connect, a dialog pops up asking to enter credentials though. when using rasdial you get error 703.
if you look at the advanced vpn settings, you see that username/password have been set correctly:
editing reveals that the checkbox for "save credentials" is not active by default.
once you manually check that and save, you can connect (also with rasdial) fine,
the VPN was created as