Solved

help with getting  custom annotations from VMWare powercli

Posted on 2015-02-04
5
461 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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

This is an issue that we can get adding / removing permissions in the vCSA 6.0. We can also have issues searching for users / groups in the AD (using your identify sources). This is how one of the ways to handle this issues and fix it.
Last article we focus in how to VMware: How to create and use VMs TAGs – Part 1 so before follow this article and perform the next tasks, you should read the first article how to create the TAG before using them in Veeam Backup Jobs.
Teach the user how to use vSphere Update Manager to update the VMware Tools and virtual machine hardware version Open vSphere Client: Review manual processes for updating VMware Tools and virtual hardware versions: Create a new baseline group in vSp…
This video shows you how to use a vSphere client to connect to your ESX host as the root user. Demonstrates the basic connection of bypassing certification set up. Demonstrates how to access the traditional view to begin managing your virtual mac…

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now