?
Solved

help with getting  custom annotations from VMWare powercli

Posted on 2015-02-04
5
Medium Priority
?
951 Views
Last Modified: 2015-02-10
I have the following script to list all VMs and their datastore. The script will list vm, datastore, provisioned and used space, and folder name. I cannot figure out how to add a a line to also list a custom attribute.

I have a custom attribute called Business.Unit. how would I add this to my script?

Get-VM |
Select Name,
@{N="Datastore";E={[string]::Join(',',(Get-Datastore -Id $_.DatastoreIdList | Select -ExpandProperty Name))}},
@{N="UsedSpaceGB";E={[math]::Round($_.UsedSpaceGB,1)}},
@{N="ProvisionedSpaceGB";E={[math]::Round($_.ProvisionedSpaceGB,1)}},
@{N="Folder";E={$_.Folder.Name}} |
Export-Csv F:\report.csv -NoTypeInformation -UseCulture
0
Comment
Question by:jsparnova
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:Dawid Fusek
ID: 40590652
You should probably to use "Get-CustomAttribute -Name Business.Unit" command and integrate it to this script.

regards
NTShad0w
0
 

Author Comment

by:jsparnova
ID: 40590940
I am able to run both commands seperatly and get the output needed. Can someone help me combine these. It looks like one is outputting to a list and the other to a table.:
PART 1:

Get-VM | Get-Annotation | Select @{N="VM";E={$_.AnnotatedEntity.Name}},Value

OUTPUT:
VM                                                     Value
--                                                     -----
IE8TESTER                                              Solutions

Part 2:
Get-VM |
Select Name,
@{N="Datastore";E={[string]::Join(',',(Get-Datastore -Id $_.DatastoreIdList | Select -ExpandProperty Name))}},
@{N="UsedSpaceGB";E={[math]::Round($_.UsedSpaceGB,1)}},
@{N="ProvisionedSpaceGB";E={[math]::Round($_.ProvisionedSpaceGB,1)}},
@{N="Folder";E={$_.Folder.Name}}

output:
Name               : IE8TESTER
Datastore          : VNXe:Storage1
UsedSpaceGB        : 13.1
ProvisionedSpaceGB : 52.3
Folder             : Discovered virtual machine
0
 

Accepted Solution

by:
jsparnova earned 0 total points
ID: 40591781
Solved this myself:

Get-VM | Select Name,
@{N="Datastore";E={[string]::Join(',',(Get-Datastore -Id $_.DatastoreIdList | Select -ExpandProperty Name))}},
@{N="UsedSpaceGB";E={[math]::Round($_.UsedSpaceGB,1)}},
@{N="ProvisionedSpaceGB";E={[math]::Round($_.ProvisionedSpaceGB,1)}},
@{N="Folder";E={$_.Folder.Name}},
@{N='Description';E={ ($_ | Get-Annotation -Name 'Description').Value}},
@{N='Category';E={ ($_ | Get-Annotation -Name 'BU').Value}}
0
 
LVL 5

Expert Comment

by:Dawid Fusek
ID: 40594715
good you found a way mate,

best regards
NTShad0w
0
 

Author Closing Comment

by:jsparnova
ID: 40600318
I figured it out myself.
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ransomware is a malware that is again in the list of security  concerns. Not only for companies, but also for Government security and  even at personal use. IT departments should be aware and have the right  knowledge to how to fight it.
In this article will go through how to backup a vPostgres DB from a broken vCenter Appliance and restore to a new vCenter Appliance.
Advanced tutorial on how to run the esxtop command to capture a batch file in csv format in order to export the file and use it for performance analysis. He demonstrates how to download the file using a vSphere web client (or vSphere client) and exp…
This Micro Tutorial steps you through the configuration steps to configure your ESXi host Management Network settings and test the management network, ensure the host is recognized by the DNS Server, configure a new password, and the troubleshooting…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question