Can anyone tell me how I can just add 1 VM to inventory in vCenter?
I found a bunch of big scripts, but they just seem excessive.
I do mean registering a VM with the .vmx file.
Thanks that's an impressive script. But is there an easy way to do this for just 1 VM and point to the location of the vmx file?
There _is_ another way. There is a "RegisterVM" ParameterSet on the New-VM cmdlet that allows for registering VMs via their .vmx file. Specifically, the "-VMFilePath" parameter allows you to register a VM by specifying a datastore path to a valid .vmx file. So, something like:
## add VM to inventory on given random host in given folder
New-VM -VMFilePath "[datastore0] myVM01/myVM01.vmx" -VMHost (Get-Cluster MyCluster | Get-VMHost | Get-Random) -Location (Get-Folder MyFolder) -RunAsync
I have not been able to pinpoint just when that parameter was added to the New-VM cmdlet, but from what I can tell, it was within the last few releases -- looks like it was there in PowerCLI v4.0u1. Could not find much (anything) about it in the release notes, though.
We posted about it over at vNugglets a bit ago: http://vnugglets.com/2011/01/re-registering-vms-removed-from.html. It definitely comes in handy now and again.
How does that do for you, scotty p?