Please tell me, how I can find and set var $vpnName if I know just part of VPN name, like “vash”, full VPN name maybe VPNvashinsider or VPN vashinsider or vpnvashinsider.com
I need regex how I can set var $vpnName taked from part of word “vash”? Thanks a lot!
Thx. I found this way:
$vpn = Get-VpnConnection -AllUserConnection | Where-Object { $_.Name -like ‘vash’ }
if($vpn.ConnectionStatus -eq “Connected”){
rasdial $vpnName /DISCONNECT;
}
But new important task, how I can set: Set-VPNconnection -name ??? -SplitTunneling $false
I’ve tried more than 100 ways and nothing… I need set Default Gateway, if I set it directly like: Set-VPNconnection -name “VPN Vashinsider” -SplitTunneling $true all is ok, but what I can do if I know part name only, like “vash” it’s important for me.
$vpn = Get-VpnConnection -AllUserConnection | Where-Object { $_.Name -like ‘vash’ } | foreach { Set-VPNconnection -name $vpn[0].Name -SplitTunneling $false } and other NOT WORKING ((((
First of all … please format your code as code here in the forum. Just like you already did in your initial question.
Have you actually tried my suggestion?
You can use the same approach like for the other task?! You query the VPN connection you’re after with Get-VPNConnection and pipe the result to Set-VPNConnection.