PowerCLI :: VMware annotation Note to Multiple VMs.


Now, I am posed with another requirement, I need to update few non-critical VMs to be taken out of backup schedule. My backup admin has a query based backup policy, where he is able to filter out VM server, which got ‘no-backup’ annotation note. Now we need to add 100s of server with this note.

Below script help us do the things. You must have PowerCLi installed and access to VMware server, and a list of server name in a text file.

This will also merge any existing  annotation note to new note

# Start Script ————————————————

#Author : Vipin Vasudevan

#List of VMs on computer.txt (mention the complete path)

#—————————————-

Add-PSSnapin VMware.VimAutomation.Core 

Connect-VIServer <vCenter Server> -credential (get-credentials)

Get-content <path>\computer.txt | foreach {

$note = “no-backup”

Get-VM -Name $_ | %{$desc= $_.Description}

$newNote = $desc+ ” ” + $note

Set-VM -VM $_ -Description $newNote -Confirm:$false;

}

# ——————————Script End——————- 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s