Advertisement
Guest User

vpnstrategy

a guest
Sep 20th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #This script checks local user VPN strategy and overrides it – this is important as Windows
  2. #dynamically changes and updates this, often to undesired settings.
  3.  
  4. #Get rasphone.pbk path for local user
  5. $RASPhone = ($env:USERPROFILE) + '\Appdata\Roaming\Microsoft\Network\Connections\Pbk\rasphone.pbk'
  6.  
  7. #Get current VPN Strategy (5=SSTP only, 6=SSTP first, then others, 7= IKEv2 only, 8=IKEv2
  8. #first, then others, 14=IKEv2 then SSTP
  9. $OldVPNStrategy = (Get-Content $RASPhone) -like "VpnStrategy=?"
  10.  
  11. #Set desired VPN Strategy – should be 14 for IKEv2 preferred and SSTP as fallback
  12. $NewVPNStrategy = "VpnStrategy=6"
  13.  
  14. #Check if current VPN Strategy matches desired, end if true, continue if false
  15. If ($OldVPNStrategy -ne $NewVPNStrategy)
  16. {
  17. (Get-Content $rasphone).Replace($OldVPNStrategy,$NewVPNStrategy) | Set-Content $RASPhone
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement