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.
Enjoy!
2 Responses to Oneliner of the day
Tags
Active Directory API bind order cleanup cluster CPU Custom Fields datastores description device management directory tree errors Event Log file name filter Fun function HA IT known issues License Server LUN multipath NIC objects Oneliner portgroups PowerCLI PowerShell profile recursive Registry Scripts security session share snapshots SQL Stat VI Toolkit VMware vSphere WMI WSUS ZenArchives
- July 2012
- July 2011
- February 2011
- January 2011
- December 2010
- May 2010
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008





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!
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/