Solved

help with getting  custom annotations from VMWare powercli

Posted on 2015-02-04
5
581 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need To Expand VMware Disk Size 50 113
The better OS Architecture 13 92
vmware workstation slow 39 122
Microsoft Teams vs Outlook Groups vs Yammer vs Socialcast 3 20
When converting a physical machine to a virtual machine using VMware vCenter Converter Standalone or vCenter Converter Enterprise, if an adapter type is not selected during the initial customization the resulting virtual machine may contain an IDE d…
In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
Teach the user how to install ESXi 5.5 and configure the management network System Requirements: ESXi Installation:  Management Network Configuration: Management Network Testing:
This video shows you how easy it is to boot from ISO images for virtual machines with the ISO images stored on a local datastore on the ESXi host.

730 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