I am trying to use powershell to create a script which I use to add vpn connections to windows 8.1 machines. For this microsoft has made the add-vpnconnection cmdlet.

When running add-vpnconnection by hand, and supplying the mandatory parameters the cmdlet works fine.

When using my script to run the cmdlet - I am requested every single optional parameter before it functions. Does anyone know why? How can I prevent this?

Powershell script:


[string]$DNSSUFFIX ,
[string]$TunnelType = "SSTP"
) #end param
Add-VpnConnection -Name "$client VPN" -ServerAddress $Remotedns -AuthenticationMethod MSChapv2 -DnsSuffix $DNSSUFFIX = "" -SplitTunneling -TunnelType $TunnelType -AllUserConnection
  • If you just run 'Add-VpnConnection -Name "$client VPN"', does it request any further information? If not, I'd say the issue is that you're passing blank values to arguments, and could possibly sort it by splatting the variables. – James Ruskin Dec 4 '14 at 10:56

After testing this, it seems that your script should have more mandatory parameters - Add-VpnConnection won't accept just the parameters passed with just your enforced ($Client).

When running the "minimal set", the return asks for further details.

Add-VpnConnection -Name "Test Name" -AuthenticationMethod MSChapv2 -SplitTunneling -AllUserConnection
cmdlet Add-VpnConnection at command pipeline position 1
Supply values for the following parameters:

If you run Get-Help against Add-VPNConnection, it seems that you'll need at least -ServerAddress ($Remotedns, in your script) to be mandatory as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.