DotRAS and Powershell

Feb 7, 2013 at 4:31 PM

I'm wondering if anyones been able to get DotRAS to work with powershell?

So i've been able to list all of the Typename using the following code
$dllpath = "C:\Program Files (x86)\DotRas SDKs\v1.3\Libraries\NET20\WIN7\DotRas.dll"
$dotras = [System.Reflection.Assembly]::LoadFrom($dllpath)
$dotras.GetExportedTypes() | Get-Member -Static 
Anyone got any ideas how I could use this to create a VPN connection? I can't seem to get the RasEntry.CreateVpnEntry command to work.

Any help or pointers would be great.

Feb 7, 2013 at 10:39 PM

Just an update on what I've done.

I've able to add a new vpn connection using powershell.
$dllpath = "C:\Program Files (x86)\DotRas SDKs\v1.3\Libraries\NET20\WIN7\DotRas.dll"

$pbk = New-Object DotRas.RasPhoneBook
$pbkUserPath = [DotRas.RasPhoneBook]::GetPhoneBookPath([DotRas.RasPhoneBookType]::AllUsers)


$entry = [DotRas.RasEntry]::CreateVpnEntry("RAS TEST", "", [DotRas.RasVpnStrategy]::PptpFirst, [DotRas.RasDevice]::GetDeviceByName("(PPTP)", [DotRas.RasDeviceType]::Vpn))
$entry.Options.RequireEAP = $true
$entry.CustomAuthKey = "13"
$entry.NetworkProtocols.IPv6 = $false

$pbk.Entries.Remove("RAS TEST")