hope this helps others...
VMware Infrastructure (VI) Toolkit (for Windows)
Using the VI Toolkit, this is the process of adding all VM custom attributes.
The first thing you need to do after launching the VI Toolkit (for Windows) is to get a connection to a VirtualCenter or ESX server. To get started, call the Connect-VIServer cmdlet and specify the IP address or DNS name of your VirtualCenter or ESX server, the protocol (http or https), user name, and password.
Connect-VIServer -Server 10.22.36.36 -protocol https -user admin -password mypass
Create a script for your desired output using textpad and save .ps1 (example below)
-
#PowerSell script to Import Custom Attributes
foreach ($f in (import-csv "output.csv"))
{
$myvm = get-vm $f.Name
set-customfield -entity $myvm -name "BUILT BY" -value $f."BUILT BY"
set-customfield -entity $myvm -name "BUSINESS AREA" -value $f."BUSINESS AREA"
set-customfield -entity $myvm -name CONTACT -value $f.CONTACT
set-customfield -entity $myvm -name "DATE ADDED" -value $f."DATE ADDED"
set-customfield -entity $myvm -name DESCRIPTION -value $f.DESCRIPTION
set-customfield -entity $myvm -name "START UP" -value $f."START UP"
set-customfield -entity $myvm -name "TO BE DELETED OR ARCHIVED / DATE?" -value $f."TO BE DELETED OR ARCHIVED / DATE?"
#add what you like but the names must be as they are in vc
}
-
As you can see this calls the "output.csv" file that is simply an export list from the source VC.
Once connected to the VC via PowerShell or VMware VI Toolkit (for windows) cmd simply run the script.
.\myscript.ps1
Sit back and watch it work for you.
JW