Skip to content

Commit 3132398

Browse files
committed
fixes
1 parent 60e39f2 commit 3132398

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

articles/virtual-network/ip-services/virtual-network-multiple-ip-addresses-powershell.md

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ New-AzVirtualNetwork @net
9797
Use [New-AzPublicIpAddress](/powershell/module/az.network/new-azpublicipaddress) to create a primary public IP address.
9898

9999
```azurepowershell-interactive
100-
$ip4-1 = @{
100+
$ip1 = @{
101101
Name = 'myPublicIP-1'
102102
ResourceGroupName = 'myResourceGroup'
103103
Location = 'eastus2'
@@ -106,7 +106,7 @@ $ip4-1 = @{
106106
IpAddressVersion = 'IPv4'
107107
Zone = 1,2,3
108108
}
109-
New-AzPublicIpAddress @ip4-1
109+
New-AzPublicIpAddress @ip1
110110
```
111111

112112
## Create a network security group
@@ -165,23 +165,16 @@ $pub1 = @{
165165
Name = 'myPublicIP-1'
166166
ResourceGroupName = 'myResourceGroup'
167167
}
168-
$pubIP-1 = Get-AzPublicIPAddress @pub1
169-
170-
## Place the secondary public IP address into a variable. ##
171-
$pub2 = @{
172-
Name = 'myPublicIP-2'
173-
ResourceGroupName = 'myResourceGroup'
174-
}
175-
$pubIP-2 = Get-AzPublicIPAddress @pub2
168+
$pubIP1 = Get-AzPublicIPAddress @pub1
176169
177170
## Create primary configuration for NIC. ##
178171
$IP1 = @{
179172
Name = 'ipconfig1'
180173
Subnet = $vnet.Subnets[0]
181174
PrivateIpAddressVersion = 'IPv4'
182-
PublicIPAddress = $pubIP-1
175+
PublicIPAddress = $pubIP1
183176
}
184-
$IP1Config = New-AzNetworkInterfaceIpConfig @IP1
177+
$IP1Config = New-AzNetworkInterfaceIpConfig @IP1 -Primary
185178
186179
## Create tertiary configuration for NIC. ##
187180
$IP3 = @{
@@ -265,7 +258,7 @@ New-AzVM @vm -GenerateSshKey
265258
Use [New-AzPublicIpAddress](/powershell/module/az.network/new-azpublicipaddress) to create a secondary public IP address.
266259

267260
```azurepowershell-interactive
268-
$ip4-2 = @{
261+
$ip2 = @{
269262
Name = 'myPublicIP-2'
270263
ResourceGroupName = 'myResourceGroup'
271264
Location = 'eastus2'
@@ -274,7 +267,7 @@ $ip4-2 = @{
274267
IpAddressVersion = 'IPv4'
275268
Zone = 1,2,3
276269
}
277-
New-AzPublicIpAddress @ip4-2
270+
New-AzPublicIpAddress @ip2
278271
```
279272

280273
Use [New-AzNetworkInterfaceIpConfig](/powershell/module/az.network/new-aznetworkinterfaceipconfig) to create the secondary IP configuration for the virtual machine.
@@ -299,7 +292,7 @@ $pip = @{
299292
Name = 'myPublicIP-2'
300293
ResourceGroupName = 'myResourceGroup'
301294
}
302-
$pubIP-2 = Get-AzPublicIPAddress @pip
295+
$pubIP2 = Get-AzPublicIPAddress @pip
303296
304297
## Place the network interface into a variable. ##
305298
$net = @{
@@ -309,14 +302,14 @@ $net = @{
309302
$nic = Get-AzNetworkInterface @net
310303
311304
## Create secondary configuration for NIC. ##
312-
$IP2 = @{
305+
$IPc2 = @{
313306
Name = 'ipconfig2'
314307
Subnet = $vnet.Subnets[0]
315308
PrivateIpAddressVersion = 'IPv4'
316309
PrivateIpAddress = '10.1.0.5'
317-
PublicIPAddress = $pubIP-2
310+
PublicIPAddress = $pubIP2
318311
}
319-
$IP2Config = New-AzNetworkInterfaceIpConfig @IP2
312+
$IP2Config = New-AzNetworkInterfaceIpConfig @IPc2
320313
321314
## Add the IP configuration to the network interface. ##
322315
$nic.IpConfigurations.Add($IP2Config)

0 commit comments

Comments
 (0)