0

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:

Param(

[Parameter(Mandatory=$true)]
[string]$Client,
[string]$Remotedns,
[string]$DNSSUFFIX ,
[string]$TunnelType = "SSTP"
) #end param
Add-VpnConnection -Name "$client VPN" -ServerAddress $Remotedns -AuthenticationMethod MSChapv2 -DnsSuffix $DNSSUFFIX = "" -SplitTunneling -TunnelType $TunnelType -AllUserConnection
1
  • 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. Dec 4, 2014 at 10:56

1 Answer 1

0

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:
ServerAddress:

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .