{"id":8366,"date":"2024-10-10T02:51:04","date_gmt":"2024-10-10T02:51:04","guid":{"rendered":"https:\/\/pariswells.com\/blog\/?p=8366"},"modified":"2024-10-10T02:51:05","modified_gmt":"2024-10-10T02:51:05","slug":"proactive-remediation-vpn-settings-powershell","status":"publish","type":"post","link":"https:\/\/pariswells.com\/blog\/research\/proactive-remediation-vpn-settings-powershell","title":{"rendered":"Proactive Remediation VPN Settings Powershell"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code class=\"\">\n$NewVPN = \"XXXXVPN\"\n$HasNew = Get-VpnConnection -AllUserConnection $NewVPN -ErrorAction SilentlyContinue\n\n#Check VPN Exists\n\nif (-not $HasNew) {\n        Write-Output \"VPN Not Found\"\n        Exit 1\n}\t\n\t\n#Check Routes\n\n$Routes = (Get-VpnConnection -Name $NewVPN -AllUserConnection).Routes.DestinationPrefix\n\nif ($Routes -contains \"10.5.0.0\/16\") { } else { \n\nWrite-Output \"US AZ Route Not Found\"\n\n   Exit 1\n   }\t\n   \n\n#Hide Filenames\n$RegPath = \"HKLM:\\SYSTEM\\CurrentControlSet\\Services\\RasMan\\PPP\"\n$Name = \"MaxConfigure\"\n$value = \"60\"\n\n#Registry Detection Template\n\nIf (!(Test-Path $RegPath))\n{\nwrite-output 'Registry needed fixing '\nExit 1\n}\n\n\n$check=(Get-ItemProperty -path $RegPath -name $Name -ErrorAction SilentlyContinue).$Name\nif ($check -ne $value){\nwrite-output 'Registry needed fixing '\nExit 1\n}\n\n\n  \n  Exit 0\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">\n\n\n$OldVPN = \"XXXXX\"\n$NewVPN = \"XXXXX\"\n$HasNew = Get-VpnConnection -AllUserConnection $NewVPN -ErrorAction SilentlyContinue\n$HasOld = Get-VpnConnection -AllUserConnection $OldVPN -ErrorAction SilentlyContinue\n$RegPath = \"HKLM:\\SYSTEM\\CurrentControlSet\\Services\\RasMan\\PPP\"\n$Name = \"MaxConfigure\"\n$value = \"60\"\nif ($HasOld) {Remove-VpnConnection -Name $OldVPN -AllUserConnection -Force -PassThru}\nif (-not $HasNew) {\nAdd-VpnConnection -Name $NewVPN `\n\t    -ServerAddress \"XXXXX\" `\n\t    -TunnelType \"sstp\" `\n\t    -EncryptionLevel \"Required\" `\n\t    -DnsSuffix \"XXXXX\" `\n\t    -AuthenticationMethod MSChapv2 `\n\t    -UseWinlogonCredential `\n\t    -AllUserConnection `\n\t    -RememberCredential `\n\t    -PassThru `\n\t    -SplitTunneling\n\t\t\n}\n\nAdd-VpnConnectionRoute -ConnectionName $NewVPN -DestinationPrefix 10.5.0.0\/16\nAdd-VpnConnectionRoute -ConnectionName $NewVPN -DestinationPrefix 10.7.0.0\/16\n\nNew-ItemProperty -Path $RegPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-8366","post","type-post","status-publish","format-standard","hentry","category-research"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/8366","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/comments?post=8366"}],"version-history":[{"count":1,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/8366\/revisions"}],"predecessor-version":[{"id":8367,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/8366\/revisions\/8367"}],"wp:attachment":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/media?parent=8366"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/categories?post=8366"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/tags?post=8366"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}