Skip to content

Commit 70bfff5

Browse files
author
Anavi Nahar
committed
MD file changes only
1 parent 23d7204 commit 70bfff5

File tree

1 file changed

+60
-22
lines changed

1 file changed

+60
-22
lines changed

src/ResourceManager/Network/Commands.Network/help/Set-AzureRmNetworkInterface.md

Lines changed: 60 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,40 +24,63 @@ The **Set-AzureRmNetworkInterface** sets the goal state for an Azure network int
2424

2525
### Example 1: Configure a network interface
2626
```
27-
PS C:\>$Nic = Get-AzureRmNetworkInterface -ResourceGroupName "ResourceGroup1" -Name "NetworkInterface1"
28-
PS C:\> $Nic.IpConfigurations[0].PrivateIpAddress = "10.0.1.20"
29-
PS C:\> $Nic.IpConfigurations[0].PrivateIpAllocationMethod = "Static"
30-
PS C:\> $Nic.Tag = @{Name = "Name"; Value = "Value"}
31-
PS C:\> Set-AzureRmNetworkInterface -NetworkInterface $Nic
27+
$Nic = Get-AzureRmNetworkInterface -ResourceGroupName "ResourceGroup1" -Name "NetworkInterface1"
28+
$Nic.IpConfigurations[0].PrivateIpAddress = "10.0.1.20"
29+
$Nic.IpConfigurations[0].PrivateIpAllocationMethod = "Static"
30+
$Nic.Tag = @{Name = "Name"; Value = "Value"}
31+
Set-AzureRmNetworkInterface -NetworkInterface $Nic
3232
```
3333

3434
This example configures a network interface.
35-
The first command creates a network interface named NetworkInterface1 in resource group ResourceGroup1.
36-
35+
The first command gets a network interface named NetworkInterface1 in resource group ResourceGroup1.
3736
The second command sets the private IP address of the IP configuration.
38-
3937
The third command sets the private IP allocation method to Static.
40-
4138
The fourth command sets a tag on the network interface.
42-
4339
The fifth command uses the information stored in the $Nic variable to set the network interface.
4440

45-
## PARAMETERS
41+
### Example 2: Change DNS settings on a network interface
42+
```
43+
$nic = Get-AzureRmNetworkInterface -ResourceGroupName "ResourceGroup1" -Name "NetworkInterface1"
44+
$nic.DnsSettings.DnsServers.Add("192.168.1.100")
45+
$nic | Set-AzureRmNetworkInterface
46+
```
4647

47-
### -NetworkInterface
48-
Specifies a **NetworkInterface** object that represents the goal state for a network interface.
48+
The first command gets a network interface named NetworkInterface1 that exists within resource group ResourceGroup1. The second command adds DNS server 192.168.1.100 to this interface. The third command applies these changes to the network interface. To remove a DNS server, follow the commands listed above, but replace ```.Add``` with ```.Remove``` in the second command.
4949

50-
```yaml
51-
Type: PSNetworkInterface
52-
Parameter Sets: (All)
53-
Aliases:
50+
### Example 3: Enable IP forwading on a network interface
51+
```
52+
$nic = Get-AzureRmNetworkInterface -ResourceGroupName "ResourceGroup1" -Name "NetworkInterface1"
53+
$nic.EnableIPForwarding = 1
54+
$nic | Set-AzureRmNetworkInterface
55+
```
56+
The first command gets an existing network interface called NetworkInterface1 and stores it in the ```$nic``` variable. The second command changes the IP forwarding value to true. Finally, the third command applies the changes to the network interface. To disable IP forwarding on a network interface, follow the sample example, but be sure to change the second command to ```$nic.EnableIPForwarding = 0```.
5457

55-
Required: True
56-
Position: Named
57-
Default value: None
58-
Accept pipeline input: True (ByValue)
59-
Accept wildcard characters: False
58+
### Example 4: Change the subnet of a network interface
6059
```
60+
$nic = Get-AzureRmNetworkInterface -ResourceGroupName "ResourceGroup1" -Name "NetworkInterface1"
61+
$vnet = Get-AzureRmVirtualNetwork -Name VNet1 -ResourceGroupName crosssubcrossversionpeering
62+
$subnet2 = Get-AzureRmVirtualNetworkSubnetConfig -Name Subnet2 -VirtualNetwork $vnet
63+
$nic.IpConfigurations[0].Subnet.Id = $subnet2.Id
64+
$nic | Set-AzureRmNetworkInterface
65+
```
66+
The first command gets the network interface NetworkInterface1 and stores it in the ```$nic``` variable. The second command gets the virtual network associated with the subnet that the network interface is going to be associated with. The second command gets the subnet and stores it in the ```$subnet2``` variable. The third command associated the primary private IP address of the network interface with the new subnet. Finally the last command applied these changes on the network interface.
67+
68+
>[!NOTE]
69+
>The IP configurations must be dynamic before you can change the subnet. If you have static IP configurations, change then to dynamic before proceeding.
70+
71+
>[!NOTE]
72+
>If the network interface has multiple IP configurations, the forth command must be done for all these IP configurations before the final ```Set-AzureRmNetworkInterface``` command is executed. This can be done as in the forth command but by replacing ```0``` with the appropriate number. If a network interface has N IP configurations, then N-1 of these commands must exist.
73+
74+
### Example 5: Associate/Dissociate a Network Security Group to a network interface
75+
```
76+
$nic = Get-AzureRmNetworkInterface -ResourceGroupName "ResourceGroup1" -Name "NetworkInterface1"
77+
$nsg = Get-AzureRmNetworkSecurityGroup -ResourceGroupName "ResourceGroup1" -Name "MyNSG"
78+
$nic.NetworkSecurityGroup = $nsg
79+
$nic | Set-AzureRmNetworkInterface
80+
```
81+
The first command gets an existing network interface called NetworkInterface1 and stores it in the ```$nic``` variable. The second command gets an existing network security group called MyNSG and stores it in the ```$nsg``` variable. The forth command assigns the ```$nsg``` to the ```$nic```. Finally, the fifth command applies the changes to the Network interface. To dissociate network security groups from a network interface, simple replace ```$nsg``` in the forth command with ```$null```.
82+
83+
## PARAMETERS
6184

6285
### -InformationAction
6386
Specifies how this cmdlet responds to an information event.
@@ -98,6 +121,21 @@ Accept pipeline input: False
98121
Accept wildcard characters: False
99122
```
100123
124+
### -NetworkInterface
125+
Specifies a **NetworkInterface** object that represents the goal state for a network interface.
126+
127+
```yaml
128+
Type: PSNetworkInterface
129+
Parameter Sets: (All)
130+
Aliases:
131+
132+
Required: True
133+
Position: Named
134+
Default value: None
135+
Accept pipeline input: True (ByValue)
136+
Accept wildcard characters: False
137+
```
138+
101139
### CommonParameters
102140
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
103141

0 commit comments

Comments
 (0)