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.

Enjoy!

Tagged with:
 

2 Responses to Oneliner of the day

  1. randy says:

    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!

  2. admin says:

    Hi, and welcome!
    Ah, a question we all ask once. You have to add the snapin:
    Add-PSSnapIn VMware.VimAutomation.Core
    Add-PSSnapIn Quest.ActiveRoles.ADManagement
    If you want to prevent typing this every time you start Powershell, add the lines to your profile. Read this for more info: http://www.peetersonline.nl/index.php/powershell/build-your-own-powershell-universe/

Leave a Reply