Skip to content

New-NBVirtualMachineInterface

Since

v1.0.4

SYNOPSIS

Creates one or more network interfaces on virtual machines in Netbox.

SYNTAX

Single (Default)

New-NBVirtualMachineInterface -Name <String> -Virtual_Machine <UInt64> [-Enabled <Boolean>]
 [-MAC_Address <String>] [-MTU <UInt16>] [-Description <String>] [-Mode <String>] [-Untagged_VLAN <UInt64>]
 [-Tagged_VLANs <UInt64[]>] [-VRF <UInt64>] [-Tags <UInt64[]>] [-Custom_Fields <Hashtable>] [-Raw]
 [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]

Bulk

New-NBVirtualMachineInterface -InputObject <PSObject> [-BatchSize <Int32>] [-Force] [-Raw]
 [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]

DESCRIPTION

Creates new network interfaces on specified virtual machines. Supports both single interface creation with individual parameters and bulk creation via pipeline input.

For bulk operations, use the -BatchSize parameter to control how many interfaces are sent per API request. This significantly improves performance when creating many VM interfaces.

EXAMPLES

EXAMPLE 1

New-NBVirtualMachineInterface -Name "eth0" -Virtual_Machine 42

Creates a new enabled interface named 'eth0' on VM ID 42.

EXAMPLE 2

$vms = Get-NBVirtualMachine -Cluster 1
$interfaces = $vms | ForEach-Object {
    [PSCustomObject]@{
        Virtual_Machine = $_.id
        Name = "eth0"
        Enabled = $true
        Description = "Primary interface"
    }
}
$interfaces | New-NBVirtualMachineInterface -BatchSize 50 -Force

Creates primary interfaces for all VMs in a cluster in bulk.

EXAMPLE 3

# Create multiple interfaces per VM
$vmId = 123
$interfaces = @(
    [PSCustomObject]@{Virtual_Machine=$vmId; Name="eth0"; Description="Management"}
    [PSCustomObject]@{Virtual_Machine=$vmId; Name="eth1"; Description="Production"}
    [PSCustomObject]@{Virtual_Machine=$vmId; Name="eth2"; Description="Backup"}
)
$interfaces | New-NBVirtualMachineInterface -Force

Creates multiple interfaces on a single VM.

PARAMETERS

-Name

The name of the interface (e.g., 'eth0', 'ens192', 'Ethernet0').

Type: String
Parameter Sets: Single
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Virtual_Machine

The database ID of the virtual machine to add the interface to.

Type: UInt64
Parameter Sets: Single
Aliases:

Required: True
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False

-Enabled

Whether the interface is enabled. Defaults to $true if not specified.

Type: Boolean
Parameter Sets: Single
Aliases:

Required: False
Position: Named
Default value: True
Accept pipeline input: False
Accept wildcard characters: False

-MAC_Address

The MAC address of the interface in format XX:XX:XX:XX:XX:XX.

Type: String
Parameter Sets: Single
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-MTU

Maximum Transmission Unit size. Common values: 1500 (standard), 9000 (jumbo).

Type: UInt16
Parameter Sets: Single
Aliases:

Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False

-Description

A description of the interface.

Type: String
Parameter Sets: Single
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Mode

VLAN mode for the interface: 'access', 'tagged', or 'tagged-all'.

Type: String
Parameter Sets: Single
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Untagged_VLAN

The database ID of the untagged/native VLAN.

Type: UInt64
Parameter Sets: Single
Aliases:

Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False

-Tagged_VLANs

Array of database IDs for tagged VLANs (for trunk ports).

Type: UInt64[]
Parameter Sets: Single
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-VRF

The database ID of the VRF for this interface.

Type: UInt64
Parameter Sets: Single
Aliases:

Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False

-Tags

Array of tag IDs to assign to this interface.

Type: UInt64[]
Parameter Sets: Single
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Custom_Fields

Hashtable of custom field values.

Type: Hashtable
Parameter Sets: Single
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-InputObject

Pipeline input for bulk operations. Each object should contain the required properties: Name, Virtual_Machine.

Type: PSObject
Parameter Sets: Bulk
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-BatchSize

Number of interfaces to create per API request in bulk mode. Default: 50, Range: 1-1000

Type: Int32
Parameter Sets: Bulk
Aliases:

Required: False
Position: Named
Default value: 100
Accept pipeline input: False
Accept wildcard characters: False

-Force

Skip confirmation prompts for bulk operations.

Type: SwitchParameter
Parameter Sets: Bulk
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Raw

Return the raw API response instead of the results array.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ProgressAction

{{ Fill ProgressAction Description }}

Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

System.Management.Automation.PSObject

NOTES

AddedInVersion: v1.0.4

Common parameters

common request params
common bulk params

https://netbox.readthedocs.io/en/stable/models/virtualization/vminterface/