Automation

 View Only
Expand all | Collapse all

combine two powercli cmds into one report

  • 1.  combine two powercli cmds into one report

    Posted May 23, 2022 10:23 PM

    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



  • 2.  RE: combine two powercli cmds into one report

    Posted May 24, 2022 09:14 PM

    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
    


  • 3.  RE: combine two powercli cmds into one report

    Posted Jun 10, 2022 04:00 AM

    Thank you !!



  • 4.  RE: combine two powercli cmds into one report

    Posted Jun 30, 2022 05:34 PM

    perfect, worked exactly, thanks LucD