title: Configure Azure Point-To-Site VPN to Virtual Network created in a ResourceGroup
body: <p>I am using the new Resource Manager interface to create my Virtual Network.  And I can't figure out how to configure a Point-To-Site VPN and get the VPN client thru the Powershell API.</p>
  
  <p>My Script:</p>
  
  <pre><code>$accountName = "a@a.com"
  $subscriptionId = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
  $vnetname = "VNet1"
  $rgname = "MyRG"
  $sharedKey = -join(97..122|%{[char]$_}|Get-Random -C 20)
  
  Get-AzureAccount -Name $accountName
  Set-AzureSubscription -SubscriptionId $subscriptionId
  New-AzureResourceGroup -Name "MyRG" -Location "Central US" -Force
  
  $subnet  = New-AzureVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -AddressPrefix '10.192.0.0/24'
  
  New-AzureVirtualNetwork -Name $vnetname -ResourceGroupName $rgname -Location "Central US" -AddressPrefix '10.0.0.0/8' -Subnet $subnet -Force
  </code></pre>
  
  <p>I go into the new Portal and only have DNS options to create, no ability to create a VPN gateway.  I tried scripting it, but couldn't figure out the point to site piece.  Any suggestions?</p>
  
  <p>Gateway script:</p>
  
  <pre><code>$gwip = New-AzurePublicIpAddress -Name ($vnetname + "gwip") -ResourceGroupName $rgname -Location $location -AllocationMethod Dynamic
  $vnet = Get-AzureVirtualNetwork -Name $vnetname -ResourceGroupName $rgname
  $subnet = Get-AzureVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -VirtualNetwork $vnet
  $gwipconfig = New-AzureVirtualNetworkGatewayIpConfig -Name ($vnetname + "gwipconfig") -SubnetId $subnet.Id -PublicIpAddressId $gwip.Id
  $gw = New-AzureVirtualNetworkGateway -Name ($vnetname + "gw1") -ResourceGroupName $rgname -Location "Central US" -IpConfigurations $gwipconfig -GatewayType Vpn -VpnType RouteBased
  $localGw = New-AzureLocalNetworkGateway -Name ($vnetname + "gw1-local") -ResourceGroupName $rgname -Location "Central US" -GatewayIpAddress $gwipconfig -AddressPrefix '172.16.0.0/24'
  
  New-AzureVirtualNetworkGatewayConnection -Name ($vnetname + "gw1-conn") -ResourceGroupName $rgname -Location "Central US" -VirtualNetworkGateway1 $gw -LocalNetworkGateway2 $localGw -ConnectionType IPsec -RoutingWeight 10 -SharedKey $sharedKey 
  </code></pre>