mgente
Contributor
Contributor

vSphere PowerCLI - Set VM's Annotations from csv

At our company we needed a simple script to update our VMs Annotations - It's not the best script ever but it works and I'd like to share it with the community:

# csv: VirtualMachine,Annotation,Value

# Load vmWare vSphere PowerCLI Module

Add-PSSnapin VMware.VimAutomation.Core

# Connect to vCenter

Connect-VIServer <vCenter> -User <user>

# Import CSV and Set Annotations

    Function VM-Selection {

       $vms = @()

       Import-Csv C:\vmware.csv |

       %{$vms += (Get-VM -Name $_.VirtualMachine | Set-Annotation -customattribute $_.Annotation -Value $_.Value)

       }

       return $vms

    }

VM-Selection



There are probably snipplets where you can find something similar - thanks for their great work!

Tags (2)
Reply
0 Kudos