DotRAS and Powershell

Feb 7, 2013 at 5:31 PM
Hi,

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.

Thanks
Feb 7, 2013 at 11:39 PM
Hi,

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"
[void][System.Reflection.Assembly]::LoadFrom($dllpath)

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

$pbk.Open($pbkUserPath)

$entry = [DotRas.RasEntry]::CreateVpnEntry("RAS TEST", "vpn.test.tv", [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")
$pbk.Entries.Add($entry)