Setting up Azure’s P2S VPN Gateway with PowerShell -Part 1/3

  • An active Azure Subscription
  • The most current version of Resource Manager PowerShell cmdlets installed. Installation info here.
Select-AzureRmSubscription -SubscriptionName "<subscriptionname>"
$VNetName = "VNet2"
$FESubName = "FrontEnd"
$GWSubName = "GatewaySubnet"
$VNetPrefix1 = ""
$FESubPrefix = ""
$GWSubPrefix = ""
$VPNClientAddressPool = ""
$RG = "VNet2-RG"$Location = "Canada Central"
$GWName = "VNet2GW"
$GWIPName = "VNet2GW-PIP"
New-AzureRmResourceGroup -Name $RG -Location $Location
$fesub = New-AzureRmVirtualNetworkSubnetConfig -Name $FESubName -AddressPrefix $FESubPrefix
$gwsub = New-AzureRmVirtualNetworkSubnetConfig -Name $GWSubName -AddressPrefix $GWSubPrefix
New-AzureRmVirtualNetwork -Name $VNetName -ResourceGroupName $RG `
-Location $Location -AddressPrefix $VNetPrefix `
-Subnet $fesub, $gwsub
$vnet = Get-AzureRmVirtualNetwork -Name $VNetName -ResourceGroupName $RG 
$subnet = Get-AzureRmVirtualNetworkSubnetConfig -Name "GatewaySubnet" -VirtualNetwork $vnet
$pip = New-AzureRmPublicIpAddress -Name $GWIPName -ResourceGroupName $RG -Location $Location -AllocationMethod Dynamic
$ipconf = New-AzureRmVirtualNetworkGatewayIpConfig -Name $GWIPconfName -Subnet $subnet -PublicIpAddress $pip
New-AzureRmVirtualNetworkGateway -Name $GWName -ResourceGroupName $RG -Location $Location `
-IpConfigurations $ipconf -GatewayType Vpn `
-VpnType RouteBased -EnableBgp $false -GatewaySku VpnGw1 `
-VpnClientProtocol "IkeV2"
$Gateway = Get-AzureRmVirtualNetworkGateway -ResourceGroupName $RG -Name $GWNameSet-AzureRmVirtualNetworkGateway -VirtualNetworkGateway $Gateway `
-VpnClientAddressPool $VPNClientAddressPool




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Living Documentation — Brief History and Evolution of the Concept

Making Sense of Progressive Web Apps

How AWS does continuous improvement

Broadcast Monitoring & Compliance Logging Platform

The State of Data Streaming

Load testing with apache-JMeter

Understanding of self and this in PHP

Leetcode 2140: Solving Questions With Brainpower

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Arlan Nugara

Arlan Nugara

More from Medium

Blaseball HoF week 10

How to Configure DHCP Option 119 in Windows DHCP Server and Cisco Switch — ICT Fella

Static libraries?

Modernise — IBM Power Systems