Files
2025-04-28 19:38:38 -04:00

6.8 KiB

New-ProxmoxVM

Creates a new virtual machine in Proxmox VE.

Syntax

New-ProxmoxVM
   -Connection <ProxmoxConnection>
   -Node <String>
   -Name <String>
   [-VMID <Int32>]
   [-Memory <Int32>]
   [-Cores <Int32>]
   [-Sockets <Int32>]
   [-DiskSize <Int32>]
   [-Storage <String>]
   [-OSType <String>]
   [-NetworkModel <String>]
   [-NetworkBridge <String>]
   [-Description <String>]
   [-Start]
   [<CommonParameters>]
New-ProxmoxVM
   -Connection <ProxmoxConnection>
   -Node <String>
   -Builder <ProxmoxVMBuilder>
   [<CommonParameters>]

Description

The New-ProxmoxVM cmdlet creates a new virtual machine in Proxmox VE. You can specify the VM parameters directly or use a VM builder object.

Parameters

-Connection

The connection to the Proxmox VE server.

Type: ProxmoxConnection
Parameter Sets: (All)
Aliases:

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

-Node

The node to create the VM on.

Type: String
Parameter Sets: (All)
Aliases:

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

-Name

The name of the VM to create.

Type: String
Parameter Sets: Direct
Aliases:

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

-VMID

The VM ID. If not specified, the next available ID will be used.

Type: Int32
Parameter Sets: Direct
Aliases:

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

-Memory

The amount of memory in MB.

Type: Int32
Parameter Sets: Direct
Aliases:

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

-Cores

The number of CPU cores.

Type: Int32
Parameter Sets: Direct
Aliases:

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

-Sockets

The number of CPU sockets.

Type: Int32
Parameter Sets: Direct
Aliases:

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

-DiskSize

The disk size in GB.

Type: Int32
Parameter Sets: Direct
Aliases:

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

-Storage

The storage location for the disk.

Type: String
Parameter Sets: Direct
Aliases:

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

-OSType

The operating system type.

Type: String
Parameter Sets: Direct
Aliases:

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

-NetworkModel

The network interface model.

Type: String
Parameter Sets: Direct
Aliases:

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

-NetworkBridge

The network bridge.

Type: String
Parameter Sets: Direct
Aliases:

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

-Description

The description of the VM.

Type: String
Parameter Sets: Direct
Aliases:

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

-Start

Whether to start the VM after creation.

Type: SwitchParameter
Parameter Sets: Direct
Aliases:

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

-Builder

A VM builder object containing the VM configuration.

Type: ProxmoxVMBuilder
Parameter Sets: Builder
Aliases:

Required: True
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

None

Outputs

PSProxmox.Models.ProxmoxVM

Notes

  • This cmdlet requires a connection to a Proxmox VE server. Use Connect-ProxmoxServer to establish a connection.
  • If the -VMID parameter is not specified, the next available ID will be used.
  • If the -Start parameter is specified, the VM will be started after creation.
  • You can use the New-ProxmoxVMBuilder cmdlet to create a VM builder object for more complex VM configurations.

Examples

Example 1: Create a basic VM

$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential)
$vm = New-ProxmoxVM -Connection $connection -Node "pve1" -Name "test-vm" -Memory 2048 -Cores 2 -DiskSize 32 -Start

This example creates a new VM with 2 GB of memory, 2 CPU cores, and a 32 GB disk, and starts it.

Example 2: Create a VM using a builder

$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential)
$builder = New-ProxmoxVMBuilder -Name "web-server"
$builder.WithMemory(4096)
        .WithCores(2)
        .WithDisk(50, "local-lvm")
        .WithNetwork("virtio", "vmbr0")
        .WithIPConfig("192.168.1.10/24", "192.168.1.1")
        .WithStart($true)

$vm = New-ProxmoxVM -Connection $connection -Node "pve1" -Builder $builder

This example creates a new VM using a builder object with 4 GB of memory, 2 CPU cores, a 50 GB disk, and a static IP address, and starts it.

Example 3: Create a VM with a specific ID

$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential)
$vm = New-ProxmoxVM -Connection $connection -Node "pve1" -Name "test-vm" -VMID 100 -Memory 2048 -Cores 2 -DiskSize 32

This example creates a new VM with ID 100.

Example 4: Create a VM with a description

$connection = Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential)
$vm = New-ProxmoxVM -Connection $connection -Node "pve1" -Name "test-vm" -Memory 2048 -Cores 2 -DiskSize 32 -Description "Test VM for development"

This example creates a new VM with a description.