New-NBVirtualMachine
Since
v1.0.4
SYNOPSIS
Creates one or more virtual machines in NetBox Virtualization module.
SYNTAX
Single (Default)
New-NBVirtualMachine -Name <String> [-Site <UInt64>] [-Cluster <UInt64>] [-Device <UInt64>]
[-Virtual_Machine_Type <UInt64>] [-Serial <String>] [-Tenant <UInt64>] [-Status <String>]
[-Description <String>] [-Role <UInt64>] [-Platform <UInt64>] [-vCPUs <UInt16>] [-Memory <UInt64>]
[-Disk <UInt64>] [-Primary_IP4 <UInt64>] [-Primary_IP6 <UInt64>] [-Custom_Fields <Hashtable>]
[-Comments <String>] [-Start_On_Boot <String>] [-Tags <Object[]>] [-Raw] [-ProgressAction <ActionPreference>]
[-WhatIf] [-Confirm] [<CommonParameters>]
Bulk
New-NBVirtualMachine -InputObject <PSObject> [-BatchSize <Int32>] [-Force] [-Tags <Object[]>] [-Raw]
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
DESCRIPTION
Creates new virtual machines in NetBox. Supports both single VM creation with individual parameters and bulk creation via pipeline input.
For bulk operations, use the -BatchSize parameter to control how many VMs are sent per API request. This significantly improves performance when importing VMs from vCenter or other sources.
EXAMPLES
EXAMPLE 1
New-NBVirtualMachine -Name "webserver01" -Cluster 1 -vCPUs 4 -Memory 8192
Creates a single VM with 4 vCPUs and 8GB RAM.
EXAMPLE 2
$vms = Get-VM | ForEach-Object {
[PSCustomObject]@{
Name = $_.Name
Cluster = 1
vCPUs = $_.NumCpu
Memory = $_.MemoryMB
Disk = [math]::Round($_.UsedSpaceGB)
Status = 'active'
}
}
$vms | New-NBVirtualMachine -BatchSize 100 -Force
Imports VMs from VMware vCenter in bulk.
PARAMETERS
-Name
The name of the virtual machine. Required for single VM creation.
Type: String
Parameter Sets: Single
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Site
The site ID. Optional in NetBox 4.x.
Type: UInt64
Parameter Sets: Single
Aliases:
Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
-Cluster
The cluster ID. Optional - VMs can be standalone in NetBox 4.x.
Type: UInt64
Parameter Sets: Single
Aliases:
Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
-Device
The device ID to attach this VM to (NetBox 4.6+). Allows a clusterless, device-bound VM.
Type: UInt64
Parameter Sets: Single
Aliases:
Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
-Virtual_Machine_Type
The virtual machine type ID (NetBox 4.6+).
Type: UInt64
Parameter Sets: Single
Aliases:
Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
-Serial
Serial number of the VM.
Type: String
Parameter Sets: Single
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Tenant
The tenant ID.
Type: UInt64
Parameter Sets: Single
Aliases:
Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
-Status
Status of the VM. Defaults to 'Active'.
Type: String
Parameter Sets: Single
Aliases:
Required: False
Position: Named
Default value: Active
Accept pipeline input: False
Accept wildcard characters: False
-Description
Description of the VM.
Type: String
Parameter Sets: Single
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Role
The role ID for the VM.
Type: UInt64
Parameter Sets: Single
Aliases:
Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
-Platform
The platform ID (e.g., VMware, Hyper-V).
Type: UInt64
Parameter Sets: Single
Aliases:
Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
-vCPUs
Number of virtual CPUs.
Type: UInt16
Parameter Sets: Single
Aliases:
Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
-Memory
Memory in MB.
Type: UInt64
Parameter Sets: Single
Aliases:
Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
-Disk
Disk space in GB.
Type: UInt64
Parameter Sets: Single
Aliases:
Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
-Primary_IP4
Primary IPv4 address ID.
Type: UInt64
Parameter Sets: Single
Aliases:
Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
-Primary_IP6
Primary IPv6 address ID.
Type: UInt64
Parameter Sets: Single
Aliases:
Required: False
Position: Named
Default value: 0
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
-Comments
Comments about the VM.
Type: String
Parameter Sets: Single
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Start_On_Boot
Boot behavior for the VM (NetBox 4.5+ only). Values: 'on', 'off', 'laststate'
Type: String
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 at minimum the Name property.
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 VMs 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
-Tags
One or more tags to assign to this object (tag names or IDs).
Type: Object[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
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
RELATED LINKS
https://netbox.readthedocs.io/en/stable/models/virtualization/virtualmachine/