I have a script I've been patching together to export a full run down on the state of my vCenter server and all it's moving parts. For some reason I can't seem to find how to add the annotations to my script. Every way I've tried results in a blank field.
Here's my script:
$regIPv4 = '(?:(?:1\d\d|2[0-5][0-5]|2[0-4]\d|0?[1-9]\d|0?0?\d)\.){3}(?:1\d\d|2[0-5][0-5]|2[0-4]\d|0?[1-9]\d|0?0?\d)'
Get-VM | Select Name, @{N='HostName';E={$_.Guest.HostName}}, @{N="IP addr";E={[string]::Join(',',($_.Guest.IPAddress | where{$_ -match $regIPv4}))}}, NumCpu, MemoryGB, Notes, PowerState | Export-Csv -path "c:\temp\vCenter.csv" -NoTypeInformation
The one annotation script I got working exports everything in a separate line. So there are like 5 different annotation fields for each VM, and each one gets it's own line. I'm trying to get them all to populate in a single line per VM, and trying to integrate this code to my existing script.
Get-VM | Get-Annotation | Select @{N="VM";E={$_.AnnotatedEntity.Name}},Name,Value | Export-Csv -path "c:\temp\Annotate.csv" -NoTypeInformation -UseCulture