PowerCLI – export import VM annotations


Quick script to export or import virtual machine annotations to/from CSV format. Very handy in situation when virtual machine was unregistered and registered back in vCenter inventory. registering VM back won’t restore virtual machine annotations.


Get-VM | ForEach-Object {
$VM = $_
$VM | Get-Annotation |`
ForEach-Object {
$Report = "" | Select-Object VM,Name,Value
$Report.VM = $VM.Name
$Report.Name = $_.Name
$Report.Value = $_.Value
} | Export-Csv -Path D:\VMAnnotations.csv -NoTypeInformation


Import-Csv -Path D:\VMAnnotations.csv | Where-Object {$_.Value} | ForEach-Object {
Get-VM $_.VM | Set-Annotation -CustomAttribute $_.Name -Value $_.Value


Source: http://communities.vmware.com/thread/325475

0 0 votes
Article Rating

Artur Krzywdzinski

Artur is Consulting Architect at Nutanix. He has been using, designing and deploying VMware based solutions since 2005 and Microsoft since 2012. He specialize in designing and implementing private and hybrid cloud solution based on VMware and Microsoft software stacks, datacenter migrations and transformation, disaster avoidance. Artur holds VMware Certified Design Expert certification (VCDX #077).

Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x

FOR FREE. Download Nutanix port diagrams

Join our mailing list to receive an email with instructions on how to download 19 port diagrams in MS Visio format.

NOTE: if you do not get an email within 1h, check your SPAM filters

You have Successfully Subscribed!

Don't miss any posts. Subscribe To Our Newsletter!!

Join our mailing list to receive the latest news and updates from www.vmwaremine.com.

You have Successfully Subscribed!

Pin It on Pinterest