Skip to content

Commit 3e59876

Browse files
committed
added posh code
1 parent 8ef1b3f commit 3e59876

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

articles/nat-gateway/tutorial-hub-spoke-route-nat.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,6 +1491,37 @@ Create the second virtual network for the second spoke of the hub and spoke netw
14911491
14921492
# [**Powershell**](#tab/powershell)
14931493
1494+
Use [New-AzVirtualNetwork](/powershell/module/az.network/new-azvirtualnetwork) to create the virtual network.
1495+
1496+
```powershell
1497+
$vnetParams = @{
1498+
ResourceGroupName = "test-rg"
1499+
Name = "vnet-spoke-2"
1500+
AddressPrefix = "10.2.0.0/16"
1501+
Location = "westus2"
1502+
}
1503+
New-AzVirtualNetwork @vnetParams
1504+
```
1505+
1506+
Use [Add-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/add-azvirtualnetworksubnetconfig) to create the subnet.
1507+
1508+
```powershell
1509+
$vnetParams = @{
1510+
ResourceGroupName = "test-rg"
1511+
Name = "vnet-spoke-2"
1512+
}
1513+
$vnet = Get-AzVirtualNetwork @vnetParams
1514+
1515+
$subnetParams = @{
1516+
VirtualNetwork = $vnet
1517+
Name = "subnet-private"
1518+
AddressPrefix = "10.2.0.0/24"
1519+
}
1520+
Add-AzVirtualNetworkSubnetConfig @subnetParams
1521+
1522+
Set-AzVirtualNetwork -VirtualNetwork $vnet
1523+
```
1524+
14941525
# [**CLI**](#tab/cli)
14951526
14961527
Use [az network vnet create](/cli/azure/network/vnet#az_network_vnet_create) to create the virtual network.

0 commit comments

Comments
 (0)