Home » Powershell » Add Notes To Multiple VM’s

Add Notes To Multiple VM’s

Note: This script will overwrite the existing Notes, so use it at your own risk!

My colleague asked me to add some notes to the VM’s so he knows what this VM is doing. So this is a nice job for PowerCLI  . In this post, you will see how powerful PowerCLI /Powershell is.  With only one line of code (one-liner),  you are able to achieve this job.

First you have to create a CSV file with the following entry’s:

VMName,Notes

DC01,Domain Controller

The second step is to run this one-liner. The one-liner will add the Notes:

Import-Csv “\*.csv” | % { Set-VM $_.VMName -Description $_.Note -Confirm:$false}

When the one-liner is ready, you will find the Notes in the vSphere Client:

Set Custom Fields

Change CSV file and added the Field entry. This Field entry will be the name of your custom field. In my case, I called Description.

VMName,Field,Note

DC01,Description,Domain Control

VC01,Discription,VCenter

The following one-liner will fix this for you: 
Import-Csv “\*.csv” | % { Get-VM $_.VMName | Set-CustomField -Name $_.Field -Value $_.Note -Confirm:$false }

After running the script, you will see the Description field with a new entry:

Leave a Reply

Your email address will not be published. Required fields are marked *

Name *
Email *
Website