Skip to content

Commit 9649b5f

Browse files
authored
Merge pull request #3621 from anavinahar/setNicHelp
Set-AzureRmNetworkInterface examples update
2 parents 6980f5b + e574f2b commit 9649b5f

File tree

2 files changed

+98
-23
lines changed

2 files changed

+98
-23
lines changed

src/ResourceManager/Network/Commands.Network/Microsoft.Azure.Commands.Network.dll-Help.xml

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48030,20 +48030,59 @@ PS C:\> $slb | Set-AzureRmLoadBalancerRuleConfig -Name "NewRule" -FrontendIPC
4803048030
</maml:alert>
4803148031
</maml:alertSet>
4803248032
<command:examples><command:example><maml:title>Example 1: Configure a network interface</maml:title>
48033-
<dev:code>PS C:\&gt;$Nic = Get-AzureRmNetworkInterface -ResourceGroupName "ResourceGroup1" -Name "NetworkInterface1"
48034-
PS C:\&gt; $Nic.IpConfigurations[0].PrivateIpAddress = "10.0.1.20"
48035-
PS C:\&gt; $Nic.IpConfigurations[0].PrivateIpAllocationMethod = "Static"
48036-
PS C:\&gt; $Nic.Tag = @{Name = "Name"; Value = "Value"}
48037-
PS C:\&gt; Set-AzureRmNetworkInterface -NetworkInterface $Nic</dev:code>
48038-
<dev:remarks><maml:para>This example configures a network interface. The first command creates a network interface named NetworkInterface1 in resource group ResourceGroup1.
48033+
<dev:code>$Nic = Get-AzureRmNetworkInterface -ResourceGroupName "ResourceGroup1" -Name "NetworkInterface1"
48034+
$Nic.IpConfigurations[0].PrivateIpAddress = "10.0.1.20"
48035+
$Nic.IpConfigurations[0].PrivateIpAllocationMethod = "Static"
48036+
$Nic.Tag = @{Name = "Name"; Value = "Value"}
48037+
Set-AzureRmNetworkInterface -NetworkInterface $Nic</dev:code>
48038+
<dev:remarks><maml:para>This example configures a network interface. The first command gets a network interface named NetworkInterface1 in resource group ResourceGroup1. The second command sets the private IP address of the IP configuration. The third command sets the private IP allocation method to Static. The fourth command sets a tag on the network interface. The fifth command uses the information stored in the $Nic variable to set the network interface.
4803948039
</maml:para>
48040-
<maml:para>The second command sets the private IP address of the IP configuration.
48040+
<maml:para></maml:para>
48041+
<maml:para></maml:para>
48042+
</dev:remarks>
48043+
</command:example>
48044+
<command:example><maml:title>Example 2: Change DNS settings on a network interface</maml:title>
48045+
<dev:code>$nic = Get-AzureRmNetworkInterface -ResourceGroupName "ResourceGroup1" -Name "NetworkInterface1"
48046+
$nic.DnsSettings.DnsServers.Add("192.168.1.100")
48047+
$nic | Set-AzureRmNetworkInterface</dev:code>
48048+
<dev:remarks><maml:para>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.
48049+
</maml:para>
48050+
<maml:para></maml:para>
48051+
<maml:para></maml:para>
48052+
</dev:remarks>
48053+
</command:example>
48054+
<command:example><maml:title>Example 3: Enable IP forwading on a network interface</maml:title>
48055+
<dev:code>$nic = Get-AzureRmNetworkInterface -ResourceGroupName "ResourceGroup1" -Name "NetworkInterface1"
48056+
$nic.EnableIPForwarding = 1
48057+
$nic | Set-AzureRmNetworkInterface</dev:code>
48058+
<dev:remarks><maml:para>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".
4804148059
</maml:para>
48042-
<maml:para>The third command sets the private IP allocation method to Static.
48060+
<maml:para></maml:para>
48061+
<maml:para></maml:para>
48062+
</dev:remarks>
48063+
</command:example>
48064+
<command:example><maml:title>Example 4: Change the subnet of a network interface</maml:title>
48065+
<dev:code>$nic = Get-AzureRmNetworkInterface -ResourceGroupName "ResourceGroup1" -Name "NetworkInterface1"
48066+
$vnet = Get-AzureRmVirtualNetwork -Name VNet1 -ResourceGroupName crosssubcrossversionpeering
48067+
$subnet2 = Get-AzureRmVirtualNetworkSubnetConfig -Name Subnet2 -VirtualNetwork $vnet
48068+
$nic.IpConfigurations[0].Subnet.Id = $subnet2.Id
48069+
$nic | Set-AzureRmNetworkInterface</dev:code>
48070+
<dev:remarks><maml:para>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.
48071+
</maml:para>
48072+
<maml:para>&gt;[!NOTE] &gt;The IP configurations must be dynamic before you can change the subnet. If you have static IP configurations, change then to dynamic before proceeding.
4804348073
</maml:para>
48044-
<maml:para>The fourth command sets a tag on the network interface.
48074+
<maml:para>&gt;[!NOTE] &gt;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.
4804548075
</maml:para>
48046-
<maml:para>The fifth command uses the information stored in the $Nic variable to set the network interface.
48076+
<maml:para></maml:para>
48077+
<maml:para></maml:para>
48078+
</dev:remarks>
48079+
</command:example>
48080+
<command:example><maml:title>Example 5: Associate/Dissociate a Network Security Group to a network interface</maml:title>
48081+
<dev:code>$nic = Get-AzureRmNetworkInterface -ResourceGroupName "ResourceGroup1" -Name "NetworkInterface1"
48082+
$nsg = Get-AzureRmNetworkSecurityGroup -ResourceGroupName "ResourceGroup1" -Name "MyNSG"
48083+
$nic.NetworkSecurityGroup = $nsg
48084+
$nic | Set-AzureRmNetworkInterface</dev:code>
48085+
<dev:remarks><maml:para>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.
4804748086
</maml:para>
4804848087
<maml:para></maml:para>
4804948088
<maml:para></maml:para>

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

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,62 @@ 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

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+
```
47+
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.
49+
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".
57+
58+
### Example 4: Change the subnet of a network interface
59+
```
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+
4583
## PARAMETERS
4684

4785
### -InformationAction
@@ -115,6 +153,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
115153
116154
[New-AzureRmNetworkInterface](./New-AzureRmNetworkInterface.md)
117155
118-
[Remove-AzureRmNetworkInterface](./Remove-AzureRmNetworkInterface.md)
119-
120-
156+
[Remove-AzureRmNetworkInterface](./Remove-AzureRmNetworkInterface.md)

0 commit comments

Comments
 (0)