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——————-