I want to export and then import VM Custom Attributes as part of a VC upgrade. I realize this can be done using some SQL wizardry but I'm useless with SQL so i was hoping there was a script that could handle it from Exports taken prior to the host migrations.
I have an entirely new VC 3.5. and will be importing attributes from two other legacy VC's
Moved to VI: VirtualCenter 2.x forum.
Edward L. Haletky
VMware Communities User Moderator
Author of the book 'VMWare ESX Server in the Enterprise: Planning and Securing Virtualization Servers', Copyright 2008 Pearson Education.
CIO Virtualization Blog: http://www.cio.com/blog/index/topic/168354
As well as the Virtualization Wiki at http://www.astroarch.com/wiki/index.php/Virtualization
I'm rusty on this... But you might want to check out my blog post:
Co-Author of VMware ESX Essentials in the Virtual Data Center
(ISBN:1420070274) from Auerbach
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.
Sit back and watch it work for you.