jsparnova
asked on
help with getting custom annotations from VMWare powercli
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-Dat astore -Id $_.DatastoreIdList | Select -ExpandProperty Name))}},
@{N="UsedSpaceGB";E={[math ]::Round($ _.UsedSpac eGB,1)}},
@{N="ProvisionedSpaceGB";E ={[math]:: Round($_.P rovisioned SpaceGB,1) }},
@{N="Folder";E={$_.Folder. Name}} |
Export-Csv F:\report.csv -NoTypeInformation -UseCulture
I have a custom attribute called Business.Unit. how would I add this to my script?
Get-VM |
Select Name,
@{N="Datastore";E={[string
@{N="UsedSpaceGB";E={[math
@{N="ProvisionedSpaceGB";E
@{N="Folder";E={$_.Folder.
Export-Csv F:\report.csv -NoTypeInformation -UseCulture
ASKER
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={$_.AnnotatedEn tity.Name} },Value
OUTPUT:
VM Value
-- -----
IE8TESTER Solutions
Part 2:
Get-VM |
Select Name,
@{N="Datastore";E={[string ]::Join(', ',(Get-Dat astore -Id $_.DatastoreIdList | Select -ExpandProperty Name))}},
@{N="UsedSpaceGB";E={[math ]::Round($ _.UsedSpac eGB,1)}},
@{N="ProvisionedSpaceGB";E ={[math]:: Round($_.P rovisioned SpaceGB,1) }},
@{N="Folder";E={$_.Folder. Name}}
output:
Name : IE8TESTER
Datastore : VNXe:Storage1
UsedSpaceGB : 13.1
ProvisionedSpaceGB : 52.3
Folder : Discovered virtual machine
PART 1:
Get-VM | Get-Annotation | Select @{N="VM";E={$_.AnnotatedEn
OUTPUT:
VM Value
-- -----
IE8TESTER Solutions
Part 2:
Get-VM |
Select Name,
@{N="Datastore";E={[string
@{N="UsedSpaceGB";E={[math
@{N="ProvisionedSpaceGB";E
@{N="Folder";E={$_.Folder.
output:
Name : IE8TESTER
Datastore : VNXe:Storage1
UsedSpaceGB : 13.1
ProvisionedSpaceGB : 52.3
Folder : Discovered virtual machine
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
good you found a way mate,
best regards
NTShad0w
best regards
NTShad0w
ASKER
I figured it out myself.
regards
NTShad0w