Automation

 View Only
  • 1.  How to get the below screenshot information using powercli

    Posted 13 days ago

    How to get the below screenshot information using powercli

    I would like to get the host and its path details 



  • 2.  RE: How to get the below screenshot information using powercli

    Posted 13 days ago

    Try something like this

    Get-Cluster -PipelineVariable cluster |
    Get-VMHost -PipelineVariable esx |
    ForEach-Object -Process {
        $hba = Get-VMHostHba -VMHost $esx
        $lun = Get-ScsiLun -VmHost $esx
        $path = Get-ScsiLunPath -ScsiLun $lun
        New-Object -TypeName PSObject -Property ([ordered]@{
                Cluster = $cluster.Name
                VMHost = $esx.Name
                Adapters = $esx.ExtensionData.Config.StorageDevice.HostBusAdapter.Count
                Targets = $esx.ExtensionData.Config.StorageDevice.MultipathInfo.Lun.Path.Count
                'Attached Devices' = $esx.ExtensionData.Config.StorageDevice.ScsiLun.where{$_.OperationalState -eq 'ok'}.Count, $esx.ExtensionData.Config.StorageDevice.ScsiLun.Count -join ' of '
                'Active Paths' = $esx.ExtensionData.Config.StorageDevice.MultipathInfo.Lun.Path.Where{$_.PathState -eq 'active'}.Count
                Datastores = (Get-Datastore -RelatedObject $esx).Count
            })
    }


    ------------------------------


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


    ------------------------------



  • 3.  RE: How to get the below screenshot information using powercli

    Posted 12 days ago

    Hi LucD,

    I am able to get the output but Targets are showing active path count. it should be target count as 4 or 5. 




  • 4.  RE: How to get the below screenshot information using powercli

    Posted 12 days ago

    Try like this

    Get-Cluster -PipelineVariable cluster |
    Get-VMHost -PipelineVariable esx |
    ForEach-Object -Process {
        New-Object -TypeName PSObject -Property ([ordered]@{
                Cluster = $cluster.Name
                VMHost = $esx.Name
                Adapters = $esx.ExtensionData.Config.StorageDevice.HostBusAdapter.Count
                Targets = ($esx.ExtensionData.Config.StorageDevice.MultipathInfo.Lun | Group-Object -Property Id).Count
                'Attached Devices' = $esx.ExtensionData.Config.StorageDevice.ScsiLun.where{ $_.OperationalState -eq 'ok' }.Count, $esx.ExtensionData.Config.StorageDevice.ScsiLun.Count -join ' of '
                'Active Paths' = $esx.ExtensionData.Config.StorageDevice.MultipathInfo.Lun.Path.Where{ $_.PathState -eq 'active' }.Count
                Datastores = (Get-Datastore -RelatedObject $esx).Count
            })
    }


    ------------------------------


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


    ------------------------------



  • 5.  RE: How to get the below screenshot information using powercli

    Posted 12 days ago

    Hi LucD,

    it now showing the attached devices count not the target. in my case, I have 5 targets in GUI




  • 6.  RE: How to get the below screenshot information using powercli

    Posted 12 days ago

    Hi LucD,

    Still I am getting the active path numbers not the targets, in my case, I see targets are 5 in GUI




  • 7.  RE: How to get the below screenshot information using powercli
    Best Answer

    Posted 12 days ago

    Check with this one

    Targets =($esx.ExtensionData.Config.StorageDevice.ScsiTopology.Adapter.Target | Measure-Object).Count


    ------------------------------


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


    ------------------------------



  • 8.  RE: How to get the below screenshot information using powercli

    Posted 11 days ago

    Thank you very much LucD. That worked perfectly :)