< Back

Add-AzureRmVMNetworkInterface

Tue Jan 29, 2019 9:36 pm

NAME Add-AzureRmVMNetworkInterface



SYNOPSIS

Adds a network interface to a virtual machine.





SYNTAX

Add-AzureRmVMNetworkInterface [-VM] <PSVirtualMachine> [-Id] <String> [[-Primary]] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]



Add-AzureRmVMNetworkInterface [-VM] <PSVirtualMachine> [-NetworkInterface]

<System.Collections.Generic.List`1[Microsoft.Azure.Management.Internal.Network.Common.INetworkInterfaceReference]> [-DefaultProfile

<IAzureContextContainer>] [<CommonParameters>]





DESCRIPTION

The Add-AzureRmVMNetworkInterface cmdlet adds a network interface to a virtual machine. You can add an interface when you create a virtual machine

or add one to an existing virtual machine.





PARAMETERS

-DefaultProfile <IAzureContextContainer>

The credentials, account, tenant, and subscription used for communication with azure.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Id <String>

Specifies the ID of a network interface to add to a virtual machine. You can use the Get-AzureRmNetworkInterface

(/powershell/module/azurerm.network/get-azurermnetworkinterface)cmdlet to obtain a network interface.



Required? true

Position? 1

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-NetworkInterface <System.Collections.Generic.List`1[Microsoft.Azure.Management.Internal.Network.Common.INetworkInterfaceReference]>

Specifies the network interface.



Required? true

Position? 1

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? false



-Primary [<SwitchParameter>]

Indicates that this cmdlet adds the network interface as the primary interface.



Required? false

Position? 2

Default value False

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-VM <PSVirtualMachine>

Specifies a local virtual machine object to which to add a network interface. To create a virtual machine, use the New-AzureRmVMConfig cmdlet.

To obtain an existing virtual machine, use the Get-AzureRmVM cmdlet.



Required? true

Position? 0

Default value None

Accept pipeline input? True (ByPropertyName, ByValue)

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

System.Collections.Generic.List`1[Microsoft.Azure.Commands.Network.Models.PSNetworkInterface]

Parameter 'NetworkInterface' accepts value of type

'System.Collections.Generic.List`1[Microsoft.Azure.Commands.Network.Models.PSNetworkInterface]' from the pipeline



PSVirtualMachine

Parameter 'VM' accepts value of type 'PSVirtualMachine' from the pipeline





OUTPUTS

Microsoft.Azure.Commands.Compute.Models.PSVirtualMachine







NOTES









Example 1: Add a network interface to a new virtual machine



PS C:\\> $VirtualMachine = New-AzureRmVMConfig -VMName "VirtualMachine07" -VMSize "Standard_A1"

PS C:\\> Add-AzureRmVMNetworkInterface -VM $VirtualMachine -Id

"/subscriptions/46fc8ea4-2de6-4179-8ab1-365da4121af4/resourceGroups/contoso/providers/Microsoft.Network/networkInterfaces/sshNIC"



The first command creates a virtual machine object, and then stores it in the $VirtualMachine variable. The command assigns a name and size to the

virtual machine.



The second command adds a network interface to the virtual machine stored in $VirtualMachine.





Example 2: Add a network interface to an existing virtual machine



PS C:\\> $VirtualMachine = Get-AzureRmVM -ResourceGroupName "ResourceGroup11" -Name "VirtualMachine07"

PS C:\\> Add-AzureRmVMNetworkInterface -VM $VirtualMachine -Id

"/subscriptions/46fc8ea4-2de6-4179-8ab1-365da4121af4/resourceGroups/contoso/providers/Microsoft.Network/networkInterfaces/sshNIC"

PS C:\\> Update-AzureRmVM -ResourceGroupName "ResourceGroup11" -VM $VirtualMachine



The first command gets the virtual machine named VirtualMachine07 by using the Get-AzureRmVM cmdlet. The command stores the virtual machine in the

$VirtualMachine variable.



The second command adds a network interface to the virtual machine stored in $VirtualMachine.



The final command updates the state of the virtual machine stored in $VirtualMachine in ResourceGroup11.







RELATED LINKS

Online Version: https://docs.microsoft.com/en-us/powers ... kinterface

New-AzureRmVMConfig

Get-AzureRmVmssDiskEncryption

Get-AzureRmAvailabilitySet