VMware Cloud Community
selvanvm707
Contributor
Contributor

combine two powercli cmds into one report

Hello All

question: i need a cmd to list the below information for a vm

vm name | vmhost | cluster | vcenter | storagepolicy | compliancestatus

i have two separate cmds fetching me this, but i need help in making this as a single cmd so that i can export-csv the same

cmd_1, get-vm|select name, vmhost, @{n='Cluster';e={$_.VMhost.Parent}}, @{n='vCenter';e={(($_.uid -split ":") -split "@")[1]}}

cmd_2, Get-SpbmEntityConfiguration| select name, StoragePolicy, ComplianceStatus

much appreciated

0 Kudos
3 Replies
LucD
Leadership
Leadership

You could do something like this

Get-VM -PipelineVariable vm | 
Get-SpbmEntityConfiguration |
Select @{N='Name';E={$vm.Name}}, 
    @{N='VMHost';E={$vm.VMHost.Name}},
    @{N='Cluster';E={$vm.VMhost.Parent.Name}},
    @{N='vCenter';E={(($vm.uid -split ":") -split "@")[1]}},
    @{N='SpbmName';E={$_.name}}, StoragePolicy, ComplianceStatus |
Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

CatherineLuke
Contributor
Contributor

Thank you !!

0 Kudos
selvanvm707
Contributor
Contributor

perfect, worked exactly, thanks LucD

0 Kudos