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?
OK. Thanks for your help.
1 person found this helpful
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?
This is great!!! Excactly what I was looking for.
Thanks a lot!