[GH-ISSUE #43] Incorrect put method for NetN parameter "Set-PveQemuConfig" #29

Closed
opened 2026-02-26 17:32:13 +03:00 by kerem · 3 comments
Owner

Originally created by @beavis108 on GitHub (Sep 8, 2025).
Original GitHub issue: https://github.com/Corsinvest/cv4pve-api-powershell/issues/43

The cmdlet Set-PveQemuConfig -PveTicket $Connection -Node $VM.node -Vmid $VM.vmid -NetN $NewConfig has an incorrect data structure for the NetN part. It is not a hashtable, proxmox need a string.

This is the correct code for the part to configure the netadapter option:

function Set-PveNodesQemuConfig
{
<#
.DESCRIPTION
Set virtual machine options (synchronous API) - You should consider using the POST method instead for any actions involving hotplug or storage allocation.
.PARAMETER PveTicket
Ticket data connection.
.PARAMETER Acpi
Enable/disable ACPI.
.PARAMETER Affinity
List of host cores used to execute guest processes, for example':' 0,5,8-11
.PARAMETER Agent
Enable/disable communication with the QEMU Guest Agent and its properties.
.PARAMETER AmdSev
Secure Encrypted Virtualization (SEV) features by AMD CPUs
.PARAMETER Arch
Virtual processor architecture. Defaults to the host. Enum: x86_64,aarch64
.PARAMETER Args_
Arbitrary arguments passed to kvm.
.PARAMETER Audio0
Configure a audio device, useful in combination with QXL/Spice.
.PARAMETER Autostart
Automatic restart after crash (currently ignored).
.PARAMETER Balloon
Amount of target RAM for the VM in MiB. Using zero disables the ballon driver.
.PARAMETER Bios
Select BIOS implementation. Enum: seabios,ovmf
.PARAMETER Boot
Specify guest boot order. Use the 'order=' sub-property as usage with no key or 'legacy=' is deprecated.
.PARAMETER Bootdisk
Enable booting from specified disk. Deprecated':' Use 'boot':' order=foo;bar' instead.
.PARAMETER Cdrom
This is an alias for option -ide2
.PARAMETER Cicustom
cloud-init':' Specify custom files to replace the automatically generated ones at start.
.PARAMETER Cipassword
cloud-init':' Password to assign the user. Using this is generally not recommended. Use ssh keys instead. Also note that older cloud-init versions do not support hashed passwords.
.PARAMETER Citype
Specifies the cloud-init configuration format. The default depends on the configured operating system type (ostype. We use the nocloud format for Linux, and configdrive2 for windows. Enum: configdrive2,nocloud,opennebula
.PARAMETER Ciupgrade
cloud-init':' do an automatic package upgrade after the first boot.
.PARAMETER Ciuser
cloud-init':' User name to change ssh keys and password for instead of the image's configured default user.
.PARAMETER Cores
The number of cores per socket.
.PARAMETER Cpu
Emulated CPU type.
.PARAMETER Cpulimit
Limit of CPU usage.
.PARAMETER Cpuunits
CPU weight for a VM, will be clamped to [1, 10000] in cgroup v2.
.PARAMETER Delete
A list of settings you want to delete.
.PARAMETER Description
Description for the VM. Shown in the web-interface VM's summary. This is saved as comment inside the configuration file.
.PARAMETER Digest
Prevent changes if current configuration file has different SHA1 digest. This can be used to prevent concurrent modifications.
.PARAMETER Efidisk0
Configure a disk for storing EFI vars. Use the special syntax STORAGE_ID':'SIZE_IN_GiB to allocate a new volume. Note that SIZE_IN_GiB is ignored here and that the default EFI vars are copied to the volume instead. Use STORAGE_ID':'0 and the 'import-from' parameter to import from an existing volume.
.PARAMETER Force
Force physical removal. Without this, we simple remove the disk from the config file and create an additional configuration entry called 'unused[n]', which contains the volume ID. Unlink of unused[n] always cause physical removal.
.PARAMETER Freeze
Freeze CPU at startup (use 'c' monitor command to start execution).
.PARAMETER Hookscript
Script that will be executed during various steps in the vms lifetime.
.PARAMETER HostpciN
Map host PCI devices into guest.
.PARAMETER Hotplug
Selectively enable hotplug features. This is a comma separated list of hotplug features':' 'network', 'disk', 'cpu', 'memory', 'usb' and 'cloudinit'. Use '0' to disable hotplug completely. Using '1' as value is an alias for the default network,disk,usb. USB hotplugging is possible for guests with machine version >= 7.1 and ostype l26 or windows > 7.
.PARAMETER Hugepages
Enable/disable hugepages memory. Enum: any,2,1024
.PARAMETER IdeN
Use volume as IDE hard disk or CD-ROM (n is 0 to 3). Use the special syntax STORAGE_ID':'SIZE_IN_GiB to allocate a new volume. Use STORAGE_ID':'0 and the 'import-from' parameter to import from an existing volume.
.PARAMETER IpconfigN
cloud-init':' Specify IP addresses and gateways for the corresponding interface.IP addresses use CIDR notation, gateways are optional but need an IP of the same type specified.The special string 'dhcp' can be used for IP addresses to use DHCP, in which case no explicitgateway should be provided.For IPv6 the special string 'auto' can be used to use stateless autoconfiguration. This requirescloud-init 19.4 or newer.If cloud-init is enabled and neither an IPv4 nor an IPv6 address is specified, it defaults to usingdhcp on IPv4.
.PARAMETER Ivshmem
Inter-VM shared memory. Useful for direct communication between VMs, or to the host.
.PARAMETER Keephugepages
Use together with hugepages. If enabled, hugepages will not not be deleted after VM shutdown and can be used for subsequent starts.
.PARAMETER Keyboard
Keyboard layout for VNC server. This option is generally not required and is often better handled from within the guest OS. Enum: de,de-ch,da,en-gb,en-us,es,fi,fr,fr-be,fr-ca,fr-ch,hu,is,it,ja,lt,mk,nl,no,pl,pt,pt-br,sv,sl,tr
.PARAMETER Kvm
Enable/disable KVM hardware virtualization.
.PARAMETER Localtime
Set the real time clock (RTC) to local time. This is enabled by default if the ostype indicates a Microsoft Windows OS.
.PARAMETER Lock
Lock/unlock the VM. Enum: backup,clone,create,migrate,rollback,snapshot,snapshot-delete,suspending,suspended
.PARAMETER Machine
Specify the QEMU machine.
.PARAMETER Memory
Memory properties.
.PARAMETER MigrateDowntime
Set maximum tolerated downtime (in seconds) for migrations. Should the migration not be able to converge in the very end, because too much newly dirtied RAM needs to be transferred, the limit will be increased automatically step-by-step until migration can converge.
.PARAMETER MigrateSpeed
Set maximum speed (in MB/s) for migrations. Value 0 is no limit.
.PARAMETER Name
Set a name for the VM. Only used on the configuration web interface.
.PARAMETER Nameserver
cloud-init':' Sets DNS server IP address for a container. Create will automatically use the setting from the host if neither searchdomain nor nameserver are set.
.PARAMETER NetN
Specify network devices.
.PARAMETER Node
The cluster node name.
.PARAMETER Numa
Enable/disable NUMA.
.PARAMETER NumaN
NUMA topology.
.PARAMETER Onboot
Specifies whether a VM will be started during system bootup.
.PARAMETER Ostype
Specify guest operating system. Enum: other,wxp,w2k,w2k3,w2k8,wvista,win7,win8,win10,win11,l24,l26,solaris
.PARAMETER ParallelN
Map host parallel devices (n is 0 to 2).
.PARAMETER Protection
Sets the protection flag of the VM. This will disable the remove VM and remove disk operations.
.PARAMETER Reboot
Allow reboot. If set to '0' the VM exit on reboot.
.PARAMETER Revert
Revert a pending change.
.PARAMETER Rng0
Configure a VirtIO-based Random Number Generator.
.PARAMETER SataN
Use volume as SATA hard disk or CD-ROM (n is 0 to 5). Use the special syntax STORAGE_ID':'SIZE_IN_GiB to allocate a new volume. Use STORAGE_ID':'0 and the 'import-from' parameter to import from an existing volume.
.PARAMETER ScsiN
Use volume as SCSI hard disk or CD-ROM (n is 0 to 30). Use the special syntax STORAGE_ID':'SIZE_IN_GiB to allocate a new volume. Use STORAGE_ID':'0 and the 'import-from' parameter to import from an existing volume.
.PARAMETER Scsihw
SCSI controller model Enum: lsi,lsi53c810,virtio-scsi-pci,virtio-scsi-single,megasas,pvscsi
.PARAMETER Searchdomain
cloud-init':' Sets DNS search domains for a container. Create will automatically use the setting from the host if neither searchdomain nor nameserver are set.
.PARAMETER SerialN
Create a serial device inside the VM (n is 0 to 3)
.PARAMETER Shares
Amount of memory shares for auto-ballooning. The larger the number is, the more memory this VM gets. Number is relative to weights of all other running VMs. Using zero disables auto-ballooning. Auto-ballooning is done by pvestatd.
.PARAMETER Skiplock
Ignore locks - only root is allowed to use this option.
.PARAMETER Smbios1
Specify SMBIOS type 1 fields.
.PARAMETER Smp
The number of CPUs. Please use option -sockets instead.
.PARAMETER Sockets
The number of CPU sockets.
.PARAMETER SpiceEnhancements
Configure additional enhancements for SPICE.
.PARAMETER Sshkeys
cloud-init':' Setup public SSH keys (one key per line, OpenSSH format).
.PARAMETER Startdate
Set the initial date of the real time clock. Valid format for date are':''now' or '2006-06-17T16':'01':'21' or '2006-06-17'.
.PARAMETER Startup
Startup and shutdown behavior. Order is a non-negative number defining the general startup order. Shutdown in done with reverse ordering. Additionally you can set the 'up' or 'down' delay in seconds, which specifies a delay to wait before the next VM is started or stopped.
.PARAMETER Tablet
Enable/disable the USB tablet device.
.PARAMETER Tags
Tags of the VM. This is only meta information.
.PARAMETER Tdf
Enable/disable time drift fix.
.PARAMETER Template
Enable/disable Template.
.PARAMETER Tpmstate0
Configure a Disk for storing TPM state. The format is fixed to 'raw'. Use the special syntax STORAGE_ID':'SIZE_IN_GiB to allocate a new volume. Note that SIZE_IN_GiB is ignored here and 4 MiB will be used instead. Use STORAGE_ID':'0 and the 'import-from' parameter to import from an existing volume.
.PARAMETER UnusedN
Reference to unused volumes. This is used internally, and should not be modified manually.
.PARAMETER UsbN
Configure an USB device (n is 0 to 4, for machine version >= 7.1 and ostype l26 or windows > 7, n can be up to 14).
.PARAMETER Vcpus
Number of hotplugged vcpus.
.PARAMETER Vga
Configure the VGA hardware.
.PARAMETER VirtioN
Use volume as VIRTIO hard disk (n is 0 to 15). Use the special syntax STORAGE_ID':'SIZE_IN_GiB to allocate a new volume. Use STORAGE_ID':'0 and the 'import-from' parameter to import from an existing volume.
.PARAMETER VirtiofsN
Configuration for sharing a directory between host and guest using Virtio-fs.
.PARAMETER Vmgenid
Set VM Generation ID. Use '1' to autogenerate on create or update, pass '0' to disable explicitly.
.PARAMETER Vmid
The (unique) ID of the VM.
.PARAMETER Vmstatestorage
Default storage for VM state volumes/files.
.PARAMETER Watchdog
Create a virtual hardware watchdog device.
.OUTPUTS
PveResponse. Return response.
#>
[OutputType([PveResponse])]
[CmdletBinding()]
Param(
[Parameter(ValueFromPipelineByPropertyName)]
[PveTicket]$PveTicket,

    [Parameter(ValueFromPipelineByPropertyName)]
    [bool]$Acpi,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Affinity,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Agent,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$AmdSev,

    [Parameter(ValueFromPipelineByPropertyName)]
    [ValidateSet('x86_64','aarch64')]
    [string]$Arch,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Args_,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Audio0,

    [Parameter(ValueFromPipelineByPropertyName)]
    [bool]$Autostart,

    [Parameter(ValueFromPipelineByPropertyName)]
    [int]$Balloon,

    [Parameter(ValueFromPipelineByPropertyName)]
    [ValidateSet('seabios','ovmf')]
    [string]$Bios,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Boot,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Bootdisk,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Cdrom,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Cicustom,

    [Parameter(ValueFromPipelineByPropertyName)]
    [SecureString]$Cipassword,

    [Parameter(ValueFromPipelineByPropertyName)]
    [ValidateSet('configdrive2','nocloud','opennebula')]
    [string]$Citype,

    [Parameter(ValueFromPipelineByPropertyName)]
    [bool]$Ciupgrade,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Ciuser,

    [Parameter(ValueFromPipelineByPropertyName)]
    [int]$Cores,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Cpu,

    [Parameter(ValueFromPipelineByPropertyName)]
    [float]$Cpulimit,

    [Parameter(ValueFromPipelineByPropertyName)]
    [int]$Cpuunits,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Delete,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Description,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Digest,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Efidisk0,

    [Parameter(ValueFromPipelineByPropertyName)]
    [bool]$Force,

    [Parameter(ValueFromPipelineByPropertyName)]
    [bool]$Freeze,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Hookscript,

    [Parameter(ValueFromPipelineByPropertyName)]
    [hashtable]$HostpciN,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Hotplug,

    [Parameter(ValueFromPipelineByPropertyName)]
    [ValidateSet('any','2','1024')]
    [string]$Hugepages,

    [Parameter(ValueFromPipelineByPropertyName)]
    [hashtable]$IdeN,

    [Parameter(ValueFromPipelineByPropertyName)]
    [hashtable]$IpconfigN,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Ivshmem,

    [Parameter(ValueFromPipelineByPropertyName)]
    [bool]$Keephugepages,

    [Parameter(ValueFromPipelineByPropertyName)]
    [ValidateSet('de','de-ch','da','en-gb','en-us','es','fi','fr','fr-be','fr-ca','fr-ch','hu','is','it','ja','lt','mk','nl','no','pl','pt','pt-br','sv','sl','tr')]
    [string]$Keyboard,

    [Parameter(ValueFromPipelineByPropertyName)]
    [bool]$Kvm,

    [Parameter(ValueFromPipelineByPropertyName)]
    [bool]$Localtime,

    [Parameter(ValueFromPipelineByPropertyName)]
    [ValidateSet('backup','clone','create','migrate','rollback','snapshot','snapshot-delete','suspending','suspended')]
    [string]$Lock,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Machine,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Memory,

    [Parameter(ValueFromPipelineByPropertyName)]
    [float]$MigrateDowntime,

    [Parameter(ValueFromPipelineByPropertyName)]
    [int]$MigrateSpeed,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Name,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Nameserver,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$NetN,

    [Parameter(Mandatory,ValueFromPipelineByPropertyName)]
    [string]$Node,

    [Parameter(ValueFromPipelineByPropertyName)]
    [bool]$Numa,

    [Parameter(ValueFromPipelineByPropertyName)]
    [hashtable]$NumaN,

    [Parameter(ValueFromPipelineByPropertyName)]
    [bool]$Onboot,

    [Parameter(ValueFromPipelineByPropertyName)]
    [ValidateSet('other','wxp','w2k','w2k3','w2k8','wvista','win7','win8','win10','win11','l24','l26','solaris')]
    [string]$Ostype,

    [Parameter(ValueFromPipelineByPropertyName)]
    [hashtable]$ParallelN,

    [Parameter(ValueFromPipelineByPropertyName)]
    [bool]$Protection,

    [Parameter(ValueFromPipelineByPropertyName)]
    [bool]$Reboot,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Revert,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Rng0,

    [Parameter(ValueFromPipelineByPropertyName)]
    [hashtable]$SataN,

    [Parameter(ValueFromPipelineByPropertyName)]
    [hashtable]$ScsiN,

    [Parameter(ValueFromPipelineByPropertyName)]
    [ValidateSet('lsi','lsi53c810','virtio-scsi-pci','virtio-scsi-single','megasas','pvscsi')]
    [string]$Scsihw,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Searchdomain,

    [Parameter(ValueFromPipelineByPropertyName)]
    [hashtable]$SerialN,

    [Parameter(ValueFromPipelineByPropertyName)]
    [int]$Shares,

    [Parameter(ValueFromPipelineByPropertyName)]
    [bool]$Skiplock,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Smbios1,

    [Parameter(ValueFromPipelineByPropertyName)]
    [int]$Smp,

    [Parameter(ValueFromPipelineByPropertyName)]
    [int]$Sockets,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$SpiceEnhancements,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Sshkeys,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Startdate,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Startup,

    [Parameter(ValueFromPipelineByPropertyName)]
    [bool]$Tablet,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Tags,

    [Parameter(ValueFromPipelineByPropertyName)]
    [bool]$Tdf,

    [Parameter(ValueFromPipelineByPropertyName)]
    [bool]$Template,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Tpmstate0,

    [Parameter(ValueFromPipelineByPropertyName)]
    [hashtable]$UnusedN,

    [Parameter(ValueFromPipelineByPropertyName)]
    [hashtable]$UsbN,

    [Parameter(ValueFromPipelineByPropertyName)]
    [int]$Vcpus,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Vga,

    [Parameter(ValueFromPipelineByPropertyName)]
    [hashtable]$VirtioN,

    [Parameter(ValueFromPipelineByPropertyName)]
    [hashtable]$VirtiofsN,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Vmgenid,

    [Parameter(Mandatory,ValueFromPipelineByPropertyName)]
    [int]$Vmid,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Vmstatestorage,

    [Parameter(ValueFromPipelineByPropertyName)]
    [string]$Watchdog
)

process {
    $parameters = @{}
    if($PSBoundParameters.ContainsKey('Acpi')) { $parameters['acpi'] = $Acpi }
    if($PSBoundParameters.ContainsKey('Affinity')) { $parameters['affinity'] = $Affinity }
    if($PSBoundParameters.ContainsKey('Agent')) { $parameters['agent'] = $Agent }
    if($PSBoundParameters.ContainsKey('AmdSev')) { $parameters['amd-sev'] = $AmdSev }
    if($PSBoundParameters.ContainsKey('Arch')) { $parameters['arch'] = $Arch }
    if($PSBoundParameters.ContainsKey('Args_')) { $parameters['args'] = $Args_ }
    if($PSBoundParameters.ContainsKey('Audio0')) { $parameters['audio0'] = $Audio0 }
    if($PSBoundParameters.ContainsKey('Autostart')) { $parameters['autostart'] = $Autostart }
    if($PSBoundParameters.ContainsKey('Balloon')) { $parameters['balloon'] = $Balloon }
    if($PSBoundParameters.ContainsKey('Bios')) { $parameters['bios'] = $Bios }
    if($PSBoundParameters.ContainsKey('Boot')) { $parameters['boot'] = $Boot }
    if($PSBoundParameters.ContainsKey('Bootdisk')) { $parameters['bootdisk'] = $Bootdisk }
    if($PSBoundParameters.ContainsKey('Cdrom')) { $parameters['cdrom'] = $Cdrom }
    if($PSBoundParameters.ContainsKey('Cicustom')) { $parameters['cicustom'] = $Cicustom }
    if($PSBoundParameters.ContainsKey('Cipassword')) { $parameters['cipassword'] = (ConvertFrom-SecureString -SecureString $Cipassword -AsPlainText) }
    if($PSBoundParameters.ContainsKey('Citype')) { $parameters['citype'] = $Citype }
    if($PSBoundParameters.ContainsKey('Ciupgrade')) { $parameters['ciupgrade'] = $Ciupgrade }
    if($PSBoundParameters.ContainsKey('Ciuser')) { $parameters['ciuser'] = $Ciuser }
    if($PSBoundParameters.ContainsKey('Cores')) { $parameters['cores'] = $Cores }
    if($PSBoundParameters.ContainsKey('Cpu')) { $parameters['cpu'] = $Cpu }
    if($PSBoundParameters.ContainsKey('Cpulimit')) { $parameters['cpulimit'] = $Cpulimit }
    if($PSBoundParameters.ContainsKey('Cpuunits')) { $parameters['cpuunits'] = $Cpuunits }
    if($PSBoundParameters.ContainsKey('Delete')) { $parameters['delete'] = $Delete }
    if($PSBoundParameters.ContainsKey('Description')) { $parameters['description'] = $Description }
    if($PSBoundParameters.ContainsKey('Digest')) { $parameters['digest'] = $Digest }
    if($PSBoundParameters.ContainsKey('Efidisk0')) { $parameters['efidisk0'] = $Efidisk0 }
    if($PSBoundParameters.ContainsKey('Force')) { $parameters['force'] = $Force }
    if($PSBoundParameters.ContainsKey('Freeze')) { $parameters['freeze'] = $Freeze }
    if($PSBoundParameters.ContainsKey('Hookscript')) { $parameters['hookscript'] = $Hookscript }
    if($PSBoundParameters.ContainsKey('Hotplug')) { $parameters['hotplug'] = $Hotplug }
    if($PSBoundParameters.ContainsKey('Hugepages')) { $parameters['hugepages'] = $Hugepages }
    if($PSBoundParameters.ContainsKey('Ivshmem')) { $parameters['ivshmem'] = $Ivshmem }
    if($PSBoundParameters.ContainsKey('Keephugepages')) { $parameters['keephugepages'] = $Keephugepages }
    if($PSBoundParameters.ContainsKey('Keyboard')) { $parameters['keyboard'] = $Keyboard }
    if($PSBoundParameters.ContainsKey('Kvm')) { $parameters['kvm'] = $Kvm }
    if($PSBoundParameters.ContainsKey('Localtime')) { $parameters['localtime'] = $Localtime }
    if($PSBoundParameters.ContainsKey('Lock')) { $parameters['lock'] = $Lock }
    if($PSBoundParameters.ContainsKey('Machine')) { $parameters['machine'] = $Machine }
    if($PSBoundParameters.ContainsKey('Memory')) { $parameters['memory'] = $Memory }
    if($PSBoundParameters.ContainsKey('MigrateDowntime')) { $parameters['migrate_downtime'] = $MigrateDowntime }
    if($PSBoundParameters.ContainsKey('MigrateSpeed')) { $parameters['migrate_speed'] = $MigrateSpeed }
    if($PSBoundParameters.ContainsKey('Name')) { $parameters['name'] = $Name }
    if($PSBoundParameters.ContainsKey('Nameserver')) { $parameters['nameserver'] = $Nameserver }
	if($PSBoundParameters.ContainsKey('NetN')) { $parameters['net0'] = $NetN }
    if($PSBoundParameters.ContainsKey('Numa')) { $parameters['numa'] = $Numa }
    if($PSBoundParameters.ContainsKey('Onboot')) { $parameters['onboot'] = $Onboot }
    if($PSBoundParameters.ContainsKey('Ostype')) { $parameters['ostype'] = $Ostype }
    if($PSBoundParameters.ContainsKey('Protection')) { $parameters['protection'] = $Protection }
    if($PSBoundParameters.ContainsKey('Reboot')) { $parameters['reboot'] = $Reboot }
    if($PSBoundParameters.ContainsKey('Revert')) { $parameters['revert'] = $Revert }
    if($PSBoundParameters.ContainsKey('Rng0')) { $parameters['rng0'] = $Rng0 }
    if($PSBoundParameters.ContainsKey('Scsihw')) { $parameters['scsihw'] = $Scsihw }
    if($PSBoundParameters.ContainsKey('Searchdomain')) { $parameters['searchdomain'] = $Searchdomain }
    if($PSBoundParameters.ContainsKey('Shares')) { $parameters['shares'] = $Shares }
    if($PSBoundParameters.ContainsKey('Skiplock')) { $parameters['skiplock'] = $Skiplock }
    if($PSBoundParameters.ContainsKey('Smbios1')) { $parameters['smbios1'] = $Smbios1 }
    if($PSBoundParameters.ContainsKey('Smp')) { $parameters['smp'] = $Smp }
    if($PSBoundParameters.ContainsKey('Sockets')) { $parameters['sockets'] = $Sockets }
    if($PSBoundParameters.ContainsKey('SpiceEnhancements')) { $parameters['spice_enhancements'] = $SpiceEnhancements }
    if($PSBoundParameters.ContainsKey('Sshkeys')) { $parameters['sshkeys'] = $Sshkeys }
    if($PSBoundParameters.ContainsKey('Startdate')) { $parameters['startdate'] = $Startdate }
    if($PSBoundParameters.ContainsKey('Startup')) { $parameters['startup'] = $Startup }
    if($PSBoundParameters.ContainsKey('Tablet')) { $parameters['tablet'] = $Tablet }
    if($PSBoundParameters.ContainsKey('Tags')) { $parameters['tags'] = $Tags }
    if($PSBoundParameters.ContainsKey('Tdf')) { $parameters['tdf'] = $Tdf }
    if($PSBoundParameters.ContainsKey('Template')) { $parameters['template'] = $Template }
    if($PSBoundParameters.ContainsKey('Tpmstate0')) { $parameters['tpmstate0'] = $Tpmstate0 }
    if($PSBoundParameters.ContainsKey('Vcpus')) { $parameters['vcpus'] = $Vcpus }
    if($PSBoundParameters.ContainsKey('Vga')) { $parameters['vga'] = $Vga }
    if($PSBoundParameters.ContainsKey('Vmgenid')) { $parameters['vmgenid'] = $Vmgenid }
    if($PSBoundParameters.ContainsKey('Vmstatestorage')) { $parameters['vmstatestorage'] = $Vmstatestorage }
    if($PSBoundParameters.ContainsKey('Watchdog')) { $parameters['watchdog'] = $Watchdog }

    if($PSBoundParameters.ContainsKey('HostpciN')) { $HostpciN.keys | ForEach-Object { $parameters['hostpci' + $_] = $HostpciN[$_] } }
    if($PSBoundParameters.ContainsKey('IdeN')) { $IdeN.keys | ForEach-Object { $parameters['ide' + $_] = $IdeN[$_] } }
    if($PSBoundParameters.ContainsKey('IpconfigN')) { $IpconfigN.keys | ForEach-Object { $parameters['ipconfig' + $_] = $IpconfigN[$_] } }
	#if($PSBoundParameters.ContainsKey('NetN')) { $NetN.keys | ForEach-Object { $parameters['net0' + $_] = $NetN[$_] } }
    if($PSBoundParameters.ContainsKey('NumaN')) { $NumaN.keys | ForEach-Object { $parameters['numa' + $_] = $NumaN[$_] } }
    if($PSBoundParameters.ContainsKey('ParallelN')) { $ParallelN.keys | ForEach-Object { $parameters['parallel' + $_] = $ParallelN[$_] } }
    if($PSBoundParameters.ContainsKey('SataN')) { $SataN.keys | ForEach-Object { $parameters['sata' + $_] = $SataN[$_] } }
    if($PSBoundParameters.ContainsKey('ScsiN')) { $ScsiN.keys | ForEach-Object { $parameters['scsi' + $_] = $ScsiN[$_] } }
    if($PSBoundParameters.ContainsKey('SerialN')) { $SerialN.keys | ForEach-Object { $parameters['serial' + $_] = $SerialN[$_] } }
    if($PSBoundParameters.ContainsKey('UnusedN')) { $UnusedN.keys | ForEach-Object { $parameters['unused' + $_] = $UnusedN[$_] } }
    if($PSBoundParameters.ContainsKey('UsbN')) { $UsbN.keys | ForEach-Object { $parameters['usb' + $_] = $UsbN[$_] } }
    if($PSBoundParameters.ContainsKey('VirtioN')) { $VirtioN.keys | ForEach-Object { $parameters['virtio' + $_] = $VirtioN[$_] } }
    if($PSBoundParameters.ContainsKey('VirtiofsN')) { $VirtiofsN.keys | ForEach-Object { $parameters['virtiofs' + $_] = $VirtiofsN[$_] } }

    return Invoke-PveRestApi -PveTicket $PveTicket -Method Set -Resource "/nodes/$Node/qemu/$Vmid/config" -Parameters $parameters
}

}

How to use the new code part:

Rebuild string

$NewConfig = "{0}={1},bridge={2},firewall={3}" -f #$NewConfig = "{0},bridge={1},firewall={2}" -f
#$NewConfig = "bridge={0}" -f $ConfigHash.model,
$ConfigHash.macaddr, $ConfigHash.bridge,
$ConfigHash.firewall

Set-PveQemuConfig -PveTicket $Connection -Node $VM.node -Vmid $VM.vmid -NetN $NewConfig

Originally created by @beavis108 on GitHub (Sep 8, 2025). Original GitHub issue: https://github.com/Corsinvest/cv4pve-api-powershell/issues/43 The cmdlet **Set-PveQemuConfig** -PveTicket $Connection -Node $VM.node -Vmid $VM.vmid -NetN $NewConfig has an incorrect data structure for the NetN part. It is not a hashtable, proxmox need a string. This is the correct code for the part to configure the netadapter option: function Set-PveNodesQemuConfig { <# .DESCRIPTION Set virtual machine options (synchronous API) - You should consider using the POST method instead for any actions involving hotplug or storage allocation. .PARAMETER PveTicket Ticket data connection. .PARAMETER Acpi Enable/disable ACPI. .PARAMETER Affinity List of host cores used to execute guest processes, for example':' 0,5,8-11 .PARAMETER Agent Enable/disable communication with the QEMU Guest Agent and its properties. .PARAMETER AmdSev Secure Encrypted Virtualization (SEV) features by AMD CPUs .PARAMETER Arch Virtual processor architecture. Defaults to the host. Enum: x86_64,aarch64 .PARAMETER Args_ Arbitrary arguments passed to kvm. .PARAMETER Audio0 Configure a audio device, useful in combination with QXL/Spice. .PARAMETER Autostart Automatic restart after crash (currently ignored). .PARAMETER Balloon Amount of target RAM for the VM in MiB. Using zero disables the ballon driver. .PARAMETER Bios Select BIOS implementation. Enum: seabios,ovmf .PARAMETER Boot Specify guest boot order. Use the 'order=' sub-property as usage with no key or 'legacy=' is deprecated. .PARAMETER Bootdisk Enable booting from specified disk. Deprecated':' Use 'boot':' order=foo;bar' instead. .PARAMETER Cdrom This is an alias for option -ide2 .PARAMETER Cicustom cloud-init':' Specify custom files to replace the automatically generated ones at start. .PARAMETER Cipassword cloud-init':' Password to assign the user. Using this is generally not recommended. Use ssh keys instead. Also note that older cloud-init versions do not support hashed passwords. .PARAMETER Citype Specifies the cloud-init configuration format. The default depends on the configured operating system type (`ostype`. We use the `nocloud` format for Linux, and `configdrive2` for windows. Enum: configdrive2,nocloud,opennebula .PARAMETER Ciupgrade cloud-init':' do an automatic package upgrade after the first boot. .PARAMETER Ciuser cloud-init':' User name to change ssh keys and password for instead of the image's configured default user. .PARAMETER Cores The number of cores per socket. .PARAMETER Cpu Emulated CPU type. .PARAMETER Cpulimit Limit of CPU usage. .PARAMETER Cpuunits CPU weight for a VM, will be clamped to \[1, 10000] in cgroup v2. .PARAMETER Delete A list of settings you want to delete. .PARAMETER Description Description for the VM. Shown in the web-interface VM's summary. This is saved as comment inside the configuration file. .PARAMETER Digest Prevent changes if current configuration file has different SHA1 digest. This can be used to prevent concurrent modifications. .PARAMETER Efidisk0 Configure a disk for storing EFI vars. Use the special syntax STORAGE_ID':'SIZE_IN_GiB to allocate a new volume. Note that SIZE_IN_GiB is ignored here and that the default EFI vars are copied to the volume instead. Use STORAGE_ID':'0 and the 'import-from' parameter to import from an existing volume. .PARAMETER Force Force physical removal. Without this, we simple remove the disk from the config file and create an additional configuration entry called 'unused\[n]', which contains the volume ID. Unlink of unused\[n] always cause physical removal. .PARAMETER Freeze Freeze CPU at startup (use 'c' monitor command to start execution). .PARAMETER Hookscript Script that will be executed during various steps in the vms lifetime. .PARAMETER HostpciN Map host PCI devices into guest. .PARAMETER Hotplug Selectively enable hotplug features. This is a comma separated list of hotplug features':' 'network', 'disk', 'cpu', 'memory', 'usb' and 'cloudinit'. Use '0' to disable hotplug completely. Using '1' as value is an alias for the default `network,disk,usb`. USB hotplugging is possible for guests with machine version >= 7.1 and ostype l26 or windows > 7. .PARAMETER Hugepages Enable/disable hugepages memory. Enum: any,2,1024 .PARAMETER IdeN Use volume as IDE hard disk or CD-ROM (n is 0 to 3). Use the special syntax STORAGE_ID':'SIZE_IN_GiB to allocate a new volume. Use STORAGE_ID':'0 and the 'import-from' parameter to import from an existing volume. .PARAMETER IpconfigN cloud-init':' Specify IP addresses and gateways for the corresponding interface.IP addresses use CIDR notation, gateways are optional but need an IP of the same type specified.The special string 'dhcp' can be used for IP addresses to use DHCP, in which case no explicitgateway should be provided.For IPv6 the special string 'auto' can be used to use stateless autoconfiguration. This requirescloud-init 19.4 or newer.If cloud-init is enabled and neither an IPv4 nor an IPv6 address is specified, it defaults to usingdhcp on IPv4. .PARAMETER Ivshmem Inter-VM shared memory. Useful for direct communication between VMs, or to the host. .PARAMETER Keephugepages Use together with hugepages. If enabled, hugepages will not not be deleted after VM shutdown and can be used for subsequent starts. .PARAMETER Keyboard Keyboard layout for VNC server. This option is generally not required and is often better handled from within the guest OS. Enum: de,de-ch,da,en-gb,en-us,es,fi,fr,fr-be,fr-ca,fr-ch,hu,is,it,ja,lt,mk,nl,no,pl,pt,pt-br,sv,sl,tr .PARAMETER Kvm Enable/disable KVM hardware virtualization. .PARAMETER Localtime Set the real time clock (RTC) to local time. This is enabled by default if the `ostype` indicates a Microsoft Windows OS. .PARAMETER Lock Lock/unlock the VM. Enum: backup,clone,create,migrate,rollback,snapshot,snapshot-delete,suspending,suspended .PARAMETER Machine Specify the QEMU machine. .PARAMETER Memory Memory properties. .PARAMETER MigrateDowntime Set maximum tolerated downtime (in seconds) for migrations. Should the migration not be able to converge in the very end, because too much newly dirtied RAM needs to be transferred, the limit will be increased automatically step-by-step until migration can converge. .PARAMETER MigrateSpeed Set maximum speed (in MB/s) for migrations. Value 0 is no limit. .PARAMETER Name Set a name for the VM. Only used on the configuration web interface. .PARAMETER Nameserver cloud-init':' Sets DNS server IP address for a container. Create will automatically use the setting from the host if neither searchdomain nor nameserver are set. .PARAMETER NetN Specify network devices. .PARAMETER Node The cluster node name. .PARAMETER Numa Enable/disable NUMA. .PARAMETER NumaN NUMA topology. .PARAMETER Onboot Specifies whether a VM will be started during system bootup. .PARAMETER Ostype Specify guest operating system. Enum: other,wxp,w2k,w2k3,w2k8,wvista,win7,win8,win10,win11,l24,l26,solaris .PARAMETER ParallelN Map host parallel devices (n is 0 to 2). .PARAMETER Protection Sets the protection flag of the VM. This will disable the remove VM and remove disk operations. .PARAMETER Reboot Allow reboot. If set to '0' the VM exit on reboot. .PARAMETER Revert Revert a pending change. .PARAMETER Rng0 Configure a VirtIO-based Random Number Generator. .PARAMETER SataN Use volume as SATA hard disk or CD-ROM (n is 0 to 5). Use the special syntax STORAGE_ID':'SIZE_IN_GiB to allocate a new volume. Use STORAGE_ID':'0 and the 'import-from' parameter to import from an existing volume. .PARAMETER ScsiN Use volume as SCSI hard disk or CD-ROM (n is 0 to 30). Use the special syntax STORAGE_ID':'SIZE_IN_GiB to allocate a new volume. Use STORAGE_ID':'0 and the 'import-from' parameter to import from an existing volume. .PARAMETER Scsihw SCSI controller model Enum: lsi,lsi53c810,virtio-scsi-pci,virtio-scsi-single,megasas,pvscsi .PARAMETER Searchdomain cloud-init':' Sets DNS search domains for a container. Create will automatically use the setting from the host if neither searchdomain nor nameserver are set. .PARAMETER SerialN Create a serial device inside the VM (n is 0 to 3) .PARAMETER Shares Amount of memory shares for auto-ballooning. The larger the number is, the more memory this VM gets. Number is relative to weights of all other running VMs. Using zero disables auto-ballooning. Auto-ballooning is done by pvestatd. .PARAMETER Skiplock Ignore locks - only root is allowed to use this option. .PARAMETER Smbios1 Specify SMBIOS type 1 fields. .PARAMETER Smp The number of CPUs. Please use option -sockets instead. .PARAMETER Sockets The number of CPU sockets. .PARAMETER SpiceEnhancements Configure additional enhancements for SPICE. .PARAMETER Sshkeys cloud-init':' Setup public SSH keys (one key per line, OpenSSH format). .PARAMETER Startdate Set the initial date of the real time clock. Valid format for date are':''now' or '2006-06-17T16':'01':'21' or '2006-06-17'. .PARAMETER Startup Startup and shutdown behavior. Order is a non-negative number defining the general startup order. Shutdown in done with reverse ordering. Additionally you can set the 'up' or 'down' delay in seconds, which specifies a delay to wait before the next VM is started or stopped. .PARAMETER Tablet Enable/disable the USB tablet device. .PARAMETER Tags Tags of the VM. This is only meta information. .PARAMETER Tdf Enable/disable time drift fix. .PARAMETER Template Enable/disable Template. .PARAMETER Tpmstate0 Configure a Disk for storing TPM state. The format is fixed to 'raw'. Use the special syntax STORAGE_ID':'SIZE_IN_GiB to allocate a new volume. Note that SIZE_IN_GiB is ignored here and 4 MiB will be used instead. Use STORAGE_ID':'0 and the 'import-from' parameter to import from an existing volume. .PARAMETER UnusedN Reference to unused volumes. This is used internally, and should not be modified manually. .PARAMETER UsbN Configure an USB device (n is 0 to 4, for machine version >= 7.1 and ostype l26 or windows > 7, n can be up to 14). .PARAMETER Vcpus Number of hotplugged vcpus. .PARAMETER Vga Configure the VGA hardware. .PARAMETER VirtioN Use volume as VIRTIO hard disk (n is 0 to 15). Use the special syntax STORAGE_ID':'SIZE_IN_GiB to allocate a new volume. Use STORAGE_ID':'0 and the 'import-from' parameter to import from an existing volume. .PARAMETER VirtiofsN Configuration for sharing a directory between host and guest using Virtio-fs. .PARAMETER Vmgenid Set VM Generation ID. Use '1' to autogenerate on create or update, pass '0' to disable explicitly. .PARAMETER Vmid The (unique) ID of the VM. .PARAMETER Vmstatestorage Default storage for VM state volumes/files. .PARAMETER Watchdog Create a virtual hardware watchdog device. .OUTPUTS PveResponse. Return response. #> [OutputType([PveResponse])] [CmdletBinding()] Param( [Parameter(ValueFromPipelineByPropertyName)] [PveTicket]$PveTicket, [Parameter(ValueFromPipelineByPropertyName)] [bool]$Acpi, [Parameter(ValueFromPipelineByPropertyName)] [string]$Affinity, [Parameter(ValueFromPipelineByPropertyName)] [string]$Agent, [Parameter(ValueFromPipelineByPropertyName)] [string]$AmdSev, [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet('x86_64','aarch64')] [string]$Arch, [Parameter(ValueFromPipelineByPropertyName)] [string]$Args_, [Parameter(ValueFromPipelineByPropertyName)] [string]$Audio0, [Parameter(ValueFromPipelineByPropertyName)] [bool]$Autostart, [Parameter(ValueFromPipelineByPropertyName)] [int]$Balloon, [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet('seabios','ovmf')] [string]$Bios, [Parameter(ValueFromPipelineByPropertyName)] [string]$Boot, [Parameter(ValueFromPipelineByPropertyName)] [string]$Bootdisk, [Parameter(ValueFromPipelineByPropertyName)] [string]$Cdrom, [Parameter(ValueFromPipelineByPropertyName)] [string]$Cicustom, [Parameter(ValueFromPipelineByPropertyName)] [SecureString]$Cipassword, [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet('configdrive2','nocloud','opennebula')] [string]$Citype, [Parameter(ValueFromPipelineByPropertyName)] [bool]$Ciupgrade, [Parameter(ValueFromPipelineByPropertyName)] [string]$Ciuser, [Parameter(ValueFromPipelineByPropertyName)] [int]$Cores, [Parameter(ValueFromPipelineByPropertyName)] [string]$Cpu, [Parameter(ValueFromPipelineByPropertyName)] [float]$Cpulimit, [Parameter(ValueFromPipelineByPropertyName)] [int]$Cpuunits, [Parameter(ValueFromPipelineByPropertyName)] [string]$Delete, [Parameter(ValueFromPipelineByPropertyName)] [string]$Description, [Parameter(ValueFromPipelineByPropertyName)] [string]$Digest, [Parameter(ValueFromPipelineByPropertyName)] [string]$Efidisk0, [Parameter(ValueFromPipelineByPropertyName)] [bool]$Force, [Parameter(ValueFromPipelineByPropertyName)] [bool]$Freeze, [Parameter(ValueFromPipelineByPropertyName)] [string]$Hookscript, [Parameter(ValueFromPipelineByPropertyName)] [hashtable]$HostpciN, [Parameter(ValueFromPipelineByPropertyName)] [string]$Hotplug, [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet('any','2','1024')] [string]$Hugepages, [Parameter(ValueFromPipelineByPropertyName)] [hashtable]$IdeN, [Parameter(ValueFromPipelineByPropertyName)] [hashtable]$IpconfigN, [Parameter(ValueFromPipelineByPropertyName)] [string]$Ivshmem, [Parameter(ValueFromPipelineByPropertyName)] [bool]$Keephugepages, [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet('de','de-ch','da','en-gb','en-us','es','fi','fr','fr-be','fr-ca','fr-ch','hu','is','it','ja','lt','mk','nl','no','pl','pt','pt-br','sv','sl','tr')] [string]$Keyboard, [Parameter(ValueFromPipelineByPropertyName)] [bool]$Kvm, [Parameter(ValueFromPipelineByPropertyName)] [bool]$Localtime, [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet('backup','clone','create','migrate','rollback','snapshot','snapshot-delete','suspending','suspended')] [string]$Lock, [Parameter(ValueFromPipelineByPropertyName)] [string]$Machine, [Parameter(ValueFromPipelineByPropertyName)] [string]$Memory, [Parameter(ValueFromPipelineByPropertyName)] [float]$MigrateDowntime, [Parameter(ValueFromPipelineByPropertyName)] [int]$MigrateSpeed, [Parameter(ValueFromPipelineByPropertyName)] [string]$Name, [Parameter(ValueFromPipelineByPropertyName)] [string]$Nameserver, [Parameter(ValueFromPipelineByPropertyName)] [string]$NetN, [Parameter(Mandatory,ValueFromPipelineByPropertyName)] [string]$Node, [Parameter(ValueFromPipelineByPropertyName)] [bool]$Numa, [Parameter(ValueFromPipelineByPropertyName)] [hashtable]$NumaN, [Parameter(ValueFromPipelineByPropertyName)] [bool]$Onboot, [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet('other','wxp','w2k','w2k3','w2k8','wvista','win7','win8','win10','win11','l24','l26','solaris')] [string]$Ostype, [Parameter(ValueFromPipelineByPropertyName)] [hashtable]$ParallelN, [Parameter(ValueFromPipelineByPropertyName)] [bool]$Protection, [Parameter(ValueFromPipelineByPropertyName)] [bool]$Reboot, [Parameter(ValueFromPipelineByPropertyName)] [string]$Revert, [Parameter(ValueFromPipelineByPropertyName)] [string]$Rng0, [Parameter(ValueFromPipelineByPropertyName)] [hashtable]$SataN, [Parameter(ValueFromPipelineByPropertyName)] [hashtable]$ScsiN, [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet('lsi','lsi53c810','virtio-scsi-pci','virtio-scsi-single','megasas','pvscsi')] [string]$Scsihw, [Parameter(ValueFromPipelineByPropertyName)] [string]$Searchdomain, [Parameter(ValueFromPipelineByPropertyName)] [hashtable]$SerialN, [Parameter(ValueFromPipelineByPropertyName)] [int]$Shares, [Parameter(ValueFromPipelineByPropertyName)] [bool]$Skiplock, [Parameter(ValueFromPipelineByPropertyName)] [string]$Smbios1, [Parameter(ValueFromPipelineByPropertyName)] [int]$Smp, [Parameter(ValueFromPipelineByPropertyName)] [int]$Sockets, [Parameter(ValueFromPipelineByPropertyName)] [string]$SpiceEnhancements, [Parameter(ValueFromPipelineByPropertyName)] [string]$Sshkeys, [Parameter(ValueFromPipelineByPropertyName)] [string]$Startdate, [Parameter(ValueFromPipelineByPropertyName)] [string]$Startup, [Parameter(ValueFromPipelineByPropertyName)] [bool]$Tablet, [Parameter(ValueFromPipelineByPropertyName)] [string]$Tags, [Parameter(ValueFromPipelineByPropertyName)] [bool]$Tdf, [Parameter(ValueFromPipelineByPropertyName)] [bool]$Template, [Parameter(ValueFromPipelineByPropertyName)] [string]$Tpmstate0, [Parameter(ValueFromPipelineByPropertyName)] [hashtable]$UnusedN, [Parameter(ValueFromPipelineByPropertyName)] [hashtable]$UsbN, [Parameter(ValueFromPipelineByPropertyName)] [int]$Vcpus, [Parameter(ValueFromPipelineByPropertyName)] [string]$Vga, [Parameter(ValueFromPipelineByPropertyName)] [hashtable]$VirtioN, [Parameter(ValueFromPipelineByPropertyName)] [hashtable]$VirtiofsN, [Parameter(ValueFromPipelineByPropertyName)] [string]$Vmgenid, [Parameter(Mandatory,ValueFromPipelineByPropertyName)] [int]$Vmid, [Parameter(ValueFromPipelineByPropertyName)] [string]$Vmstatestorage, [Parameter(ValueFromPipelineByPropertyName)] [string]$Watchdog ) process { $parameters = @{} if($PSBoundParameters.ContainsKey('Acpi')) { $parameters['acpi'] = $Acpi } if($PSBoundParameters.ContainsKey('Affinity')) { $parameters['affinity'] = $Affinity } if($PSBoundParameters.ContainsKey('Agent')) { $parameters['agent'] = $Agent } if($PSBoundParameters.ContainsKey('AmdSev')) { $parameters['amd-sev'] = $AmdSev } if($PSBoundParameters.ContainsKey('Arch')) { $parameters['arch'] = $Arch } if($PSBoundParameters.ContainsKey('Args_')) { $parameters['args'] = $Args_ } if($PSBoundParameters.ContainsKey('Audio0')) { $parameters['audio0'] = $Audio0 } if($PSBoundParameters.ContainsKey('Autostart')) { $parameters['autostart'] = $Autostart } if($PSBoundParameters.ContainsKey('Balloon')) { $parameters['balloon'] = $Balloon } if($PSBoundParameters.ContainsKey('Bios')) { $parameters['bios'] = $Bios } if($PSBoundParameters.ContainsKey('Boot')) { $parameters['boot'] = $Boot } if($PSBoundParameters.ContainsKey('Bootdisk')) { $parameters['bootdisk'] = $Bootdisk } if($PSBoundParameters.ContainsKey('Cdrom')) { $parameters['cdrom'] = $Cdrom } if($PSBoundParameters.ContainsKey('Cicustom')) { $parameters['cicustom'] = $Cicustom } if($PSBoundParameters.ContainsKey('Cipassword')) { $parameters['cipassword'] = (ConvertFrom-SecureString -SecureString $Cipassword -AsPlainText) } if($PSBoundParameters.ContainsKey('Citype')) { $parameters['citype'] = $Citype } if($PSBoundParameters.ContainsKey('Ciupgrade')) { $parameters['ciupgrade'] = $Ciupgrade } if($PSBoundParameters.ContainsKey('Ciuser')) { $parameters['ciuser'] = $Ciuser } if($PSBoundParameters.ContainsKey('Cores')) { $parameters['cores'] = $Cores } if($PSBoundParameters.ContainsKey('Cpu')) { $parameters['cpu'] = $Cpu } if($PSBoundParameters.ContainsKey('Cpulimit')) { $parameters['cpulimit'] = $Cpulimit } if($PSBoundParameters.ContainsKey('Cpuunits')) { $parameters['cpuunits'] = $Cpuunits } if($PSBoundParameters.ContainsKey('Delete')) { $parameters['delete'] = $Delete } if($PSBoundParameters.ContainsKey('Description')) { $parameters['description'] = $Description } if($PSBoundParameters.ContainsKey('Digest')) { $parameters['digest'] = $Digest } if($PSBoundParameters.ContainsKey('Efidisk0')) { $parameters['efidisk0'] = $Efidisk0 } if($PSBoundParameters.ContainsKey('Force')) { $parameters['force'] = $Force } if($PSBoundParameters.ContainsKey('Freeze')) { $parameters['freeze'] = $Freeze } if($PSBoundParameters.ContainsKey('Hookscript')) { $parameters['hookscript'] = $Hookscript } if($PSBoundParameters.ContainsKey('Hotplug')) { $parameters['hotplug'] = $Hotplug } if($PSBoundParameters.ContainsKey('Hugepages')) { $parameters['hugepages'] = $Hugepages } if($PSBoundParameters.ContainsKey('Ivshmem')) { $parameters['ivshmem'] = $Ivshmem } if($PSBoundParameters.ContainsKey('Keephugepages')) { $parameters['keephugepages'] = $Keephugepages } if($PSBoundParameters.ContainsKey('Keyboard')) { $parameters['keyboard'] = $Keyboard } if($PSBoundParameters.ContainsKey('Kvm')) { $parameters['kvm'] = $Kvm } if($PSBoundParameters.ContainsKey('Localtime')) { $parameters['localtime'] = $Localtime } if($PSBoundParameters.ContainsKey('Lock')) { $parameters['lock'] = $Lock } if($PSBoundParameters.ContainsKey('Machine')) { $parameters['machine'] = $Machine } if($PSBoundParameters.ContainsKey('Memory')) { $parameters['memory'] = $Memory } if($PSBoundParameters.ContainsKey('MigrateDowntime')) { $parameters['migrate_downtime'] = $MigrateDowntime } if($PSBoundParameters.ContainsKey('MigrateSpeed')) { $parameters['migrate_speed'] = $MigrateSpeed } if($PSBoundParameters.ContainsKey('Name')) { $parameters['name'] = $Name } if($PSBoundParameters.ContainsKey('Nameserver')) { $parameters['nameserver'] = $Nameserver } if($PSBoundParameters.ContainsKey('NetN')) { $parameters['net0'] = $NetN } if($PSBoundParameters.ContainsKey('Numa')) { $parameters['numa'] = $Numa } if($PSBoundParameters.ContainsKey('Onboot')) { $parameters['onboot'] = $Onboot } if($PSBoundParameters.ContainsKey('Ostype')) { $parameters['ostype'] = $Ostype } if($PSBoundParameters.ContainsKey('Protection')) { $parameters['protection'] = $Protection } if($PSBoundParameters.ContainsKey('Reboot')) { $parameters['reboot'] = $Reboot } if($PSBoundParameters.ContainsKey('Revert')) { $parameters['revert'] = $Revert } if($PSBoundParameters.ContainsKey('Rng0')) { $parameters['rng0'] = $Rng0 } if($PSBoundParameters.ContainsKey('Scsihw')) { $parameters['scsihw'] = $Scsihw } if($PSBoundParameters.ContainsKey('Searchdomain')) { $parameters['searchdomain'] = $Searchdomain } if($PSBoundParameters.ContainsKey('Shares')) { $parameters['shares'] = $Shares } if($PSBoundParameters.ContainsKey('Skiplock')) { $parameters['skiplock'] = $Skiplock } if($PSBoundParameters.ContainsKey('Smbios1')) { $parameters['smbios1'] = $Smbios1 } if($PSBoundParameters.ContainsKey('Smp')) { $parameters['smp'] = $Smp } if($PSBoundParameters.ContainsKey('Sockets')) { $parameters['sockets'] = $Sockets } if($PSBoundParameters.ContainsKey('SpiceEnhancements')) { $parameters['spice_enhancements'] = $SpiceEnhancements } if($PSBoundParameters.ContainsKey('Sshkeys')) { $parameters['sshkeys'] = $Sshkeys } if($PSBoundParameters.ContainsKey('Startdate')) { $parameters['startdate'] = $Startdate } if($PSBoundParameters.ContainsKey('Startup')) { $parameters['startup'] = $Startup } if($PSBoundParameters.ContainsKey('Tablet')) { $parameters['tablet'] = $Tablet } if($PSBoundParameters.ContainsKey('Tags')) { $parameters['tags'] = $Tags } if($PSBoundParameters.ContainsKey('Tdf')) { $parameters['tdf'] = $Tdf } if($PSBoundParameters.ContainsKey('Template')) { $parameters['template'] = $Template } if($PSBoundParameters.ContainsKey('Tpmstate0')) { $parameters['tpmstate0'] = $Tpmstate0 } if($PSBoundParameters.ContainsKey('Vcpus')) { $parameters['vcpus'] = $Vcpus } if($PSBoundParameters.ContainsKey('Vga')) { $parameters['vga'] = $Vga } if($PSBoundParameters.ContainsKey('Vmgenid')) { $parameters['vmgenid'] = $Vmgenid } if($PSBoundParameters.ContainsKey('Vmstatestorage')) { $parameters['vmstatestorage'] = $Vmstatestorage } if($PSBoundParameters.ContainsKey('Watchdog')) { $parameters['watchdog'] = $Watchdog } if($PSBoundParameters.ContainsKey('HostpciN')) { $HostpciN.keys | ForEach-Object { $parameters['hostpci' + $_] = $HostpciN[$_] } } if($PSBoundParameters.ContainsKey('IdeN')) { $IdeN.keys | ForEach-Object { $parameters['ide' + $_] = $IdeN[$_] } } if($PSBoundParameters.ContainsKey('IpconfigN')) { $IpconfigN.keys | ForEach-Object { $parameters['ipconfig' + $_] = $IpconfigN[$_] } } #if($PSBoundParameters.ContainsKey('NetN')) { $NetN.keys | ForEach-Object { $parameters['net0' + $_] = $NetN[$_] } } if($PSBoundParameters.ContainsKey('NumaN')) { $NumaN.keys | ForEach-Object { $parameters['numa' + $_] = $NumaN[$_] } } if($PSBoundParameters.ContainsKey('ParallelN')) { $ParallelN.keys | ForEach-Object { $parameters['parallel' + $_] = $ParallelN[$_] } } if($PSBoundParameters.ContainsKey('SataN')) { $SataN.keys | ForEach-Object { $parameters['sata' + $_] = $SataN[$_] } } if($PSBoundParameters.ContainsKey('ScsiN')) { $ScsiN.keys | ForEach-Object { $parameters['scsi' + $_] = $ScsiN[$_] } } if($PSBoundParameters.ContainsKey('SerialN')) { $SerialN.keys | ForEach-Object { $parameters['serial' + $_] = $SerialN[$_] } } if($PSBoundParameters.ContainsKey('UnusedN')) { $UnusedN.keys | ForEach-Object { $parameters['unused' + $_] = $UnusedN[$_] } } if($PSBoundParameters.ContainsKey('UsbN')) { $UsbN.keys | ForEach-Object { $parameters['usb' + $_] = $UsbN[$_] } } if($PSBoundParameters.ContainsKey('VirtioN')) { $VirtioN.keys | ForEach-Object { $parameters['virtio' + $_] = $VirtioN[$_] } } if($PSBoundParameters.ContainsKey('VirtiofsN')) { $VirtiofsN.keys | ForEach-Object { $parameters['virtiofs' + $_] = $VirtiofsN[$_] } } return Invoke-PveRestApi -PveTicket $PveTicket -Method Set -Resource "/nodes/$Node/qemu/$Vmid/config" -Parameters $parameters } } How to use the new code part: # Rebuild string $NewConfig = "{0}={1},bridge={2},firewall={3}" -f ` #$NewConfig = "{0},bridge={1},firewall={2}" -f ` #$NewConfig = "bridge={0}" -f ` $ConfigHash.model, ` $ConfigHash.macaddr, ` $ConfigHash.bridge, ` $ConfigHash.firewall Set-PveQemuConfig -PveTicket $Connection -Node $VM.node -Vmid $VM.vmid -NetN $NewConfig
kerem closed this issue 2026-02-26 17:32:13 +03:00
Author
Owner

@beavis108 commented on GitHub (Sep 8, 2025):

Add following parameters:
[Parameter(ValueFromPipelineByPropertyName)]
[string]$NetN,

[Parameter(ValueFromPipelineByPropertyName)]
[int]$NetId,

Add parameter process:
if($PSBoundParameters.ContainsKey('NetN')) { $parameters["net$NetId"] = $NetN }

Remove or comment out:
#if($PSBoundParameters.ContainsKey('NetN')) { $NetN.keys | ForEach-Object { $parameters['net' + $] = $NetN[$] } }

How to use cmdlet:
Set-PveQemuConfig -PveTicket $Connection -Node $VM.node -Vmid $VM.vmid -NetId 1 -NetN $NewConfig

<!-- gh-comment-id:3267357599 --> @beavis108 commented on GitHub (Sep 8, 2025): Add following parameters: [Parameter(ValueFromPipelineByPropertyName)] [string]$NetN, [Parameter(ValueFromPipelineByPropertyName)] [int]$NetId, Add parameter process: if($PSBoundParameters.ContainsKey('NetN')) { $parameters["net$NetId"] = $NetN } Remove or comment out: #if($PSBoundParameters.ContainsKey('NetN')) { $NetN.keys | ForEach-Object { $parameters['net' + $_] = $NetN[$_] } } How to use cmdlet: Set-PveQemuConfig -PveTicket $Connection -Node $VM.node -Vmid $VM.vmid -NetId 1 -NetN $NewConfig
Author
Owner

@franklupo commented on GitHub (Sep 9, 2025):

-NetN @{1='name=eth0,bridge=vmbr0,ip=dhcp'}
<!-- gh-comment-id:3270671179 --> @franklupo commented on GitHub (Sep 9, 2025): ```pwsh -NetN @{1='name=eth0,bridge=vmbr0,ip=dhcp'} ```
Author
Owner

@franklupo commented on GitHub (Sep 10, 2025):

News?

<!-- gh-comment-id:3274367895 --> @franklupo commented on GitHub (Sep 10, 2025): News?
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/cv4pve-api-powershell#29
No description provided.