VMware Cloud Community
chakoe
Enthusiast
Enthusiast

Setting Custom-Fields via New-VM?

Hi,

in our environment we have a custom field for the VM´s which is named "Kostenstelle".

I´ve build a little script to create my VM´s. With this script I am also setting the Description of the VM. Now

I want to set the Value for the custom field "Kostenstelle".

Can anyone help?

Thx

Chakoe

0 Kudos
1 Reply
LucD
Leadership
Leadership

There is currently no parameter on the New-VM cmdlet for custom attributes (like there is for the Description property), but you can "pipe" the output of the New-VM cmdlet to the Set-CustomField cmdlet.

Something like this for example

New-VM -Name "PC1" -Description "PC1" -Datastore (Get-Datastore <dsname>) -VMHost (Get-VMHost <esxname>) | Set-CustomField -Name "Kostenstelle" -Value <some-value>


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos