Oneliner of the day

Do your fellow VMware Admins sometimes forget to fill in the Notes field for a new vm they create? Or would you like to change those inconsistent notes to something more accurate? Todays oneliner simply copies the Active Directory description field into your Virtual Infrastructure. It’s quite blunt about it. Besides asking if you really want to do so, it shows a lot of errors for servers that are powered off or cannot be found in AD. But it pretty much does the trick.

Get-VM | ForEach { Set-VM -VM $_ -Description (Get-QADComputer ($_ | Get-View).Guest.HostName.Split(“.”)[0]).Description }

If your vm’s always have the same name as defined in the VM Guest OS, you can suffice with:

Get-VM | ForEach { Set-VM -VM $_ -Description (Get-QADComputer $_.Name).Description }

If you want more advanced description synching, check out the full script.


2 thoughts on “Oneliner of the day

  1. This script will be great to for what I need! I’m pretty new to PS so excuse the rookie question but I’ve loaded the Quest AD stuff and the VI toolkit but I can only run “get-VICommand” from the console launched from the vi-toolkit install and the same for get-QADComputer. How do I get these to run from together? Thanks!

Leave a Reply