VMware Cloud Community
jvm2016
Hot Shot
Hot Shot
Jump to solution

storage make and model at datacneter level_powercli

Hello Luc,

is there any way i can find storage make and model using powercli@datacenterlevel.

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You mean something like this?

Get-Datacenter | Get-VMHost | %{

    $esxcli = Get-EsxCli -VMHost $_ -V2

    $esxcli.storage.core.device.list.Invoke() | where{$_.DeviceType -eq 'Direct-Access'} |

    Select @{N='VMHost';E={$esxcli.VMHost.Name}},Vendor,Model

}


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

View solution in original post

0 Kudos
9 Replies
LucD
Leadership
Leadership
Jump to solution

You mean something like this?

Get-Datacenter | Get-VMHost | %{

    $esxcli = Get-EsxCli -VMHost $_ -V2

    $esxcli.storage.core.device.list.Invoke() | where{$_.DeviceType -eq 'Direct-Access'} |

    Select @{N='VMHost';E={$esxcli.VMHost.Name}},Vendor,Model

}


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

0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

actually i want to add this info in our previous infra report .

if i add the way yu suggested it will add one more loop for each esxi host that will a very big report.

i want to add in $dc loop .hope iam making sense.

$report = @()

$conn=$global:defaultviserver

$i = 0

foreach($vc in $global:DefaultVIServers){

    $i++

    $datacenters = Get-View -ViewType Datacenter -Property Name -Server $vc

    $vcclusters = Get-View -ViewType ClusterComputeResource -Property Name -Server $vc

    $vcvmhost = Get-View -ViewType HostSystem -Property Name -Server $vc

    $vcvm = Get-View -ViewType VirtualMachine -Property Name,Guest.GuestFamily -Server $vc

    $datastores=get-view -viewtype datastore -property name -server $vc

    foreach ($dc in $datacenters) {

  

        $clusters = Get-View -ViewType ClusterComputeResource -Property Name -SearchRoot $dc.moref  -Server $vc

        $dcvmhost = Get-View -ViewType HostSystem -Property Name -SearchRoot $dc.MoRef -Server $vc

        $vDS=get-view -viewtype distributedvirtualswitch -property name -searchroot $dc.moref -server $vc

        here

        foreach($cl in $clusters){

            $vm = Get-View -ViewType VirtualMachine -Property Name,Guest.GuestFamily -SearchRoot $cl.MoRef -Server $vc

            $vmhost = Get-View -ViewType HostSystem -Property Name -SearchRoot $cl.MoRef  -Server $vc

        

            $output = New-Object -TypeName PSObject

            $output|Add-Member -MemberType NoteProperty -Name 'vCenter' -Value $vc.Name

            $output|Add-Member -MemberType NoteProperty -Name 'Datacenters in vCenter' -Value $datacenters.Count

            $output|Add-Member -MemberType NoteProperty -Name 'Total Clusters in vCenter' -Value $vcclusters.count

            $output|Add-Member -MemberType NoteProperty -Name 'Total ESXi in vCenter' -Value $vcvmhost.count

            $output|Add-Member -MemberType NoteProperty -Name 'Total VMs in vCenter' -Value $vcvm.count

            $output|Add-Member -MemberType NoteProperty -Name 'total datastores in vcenter' -value $datastores.count

            $output|Add-Member -MemberType NoteProperty -Name 'Total Windows VM in vCenter' -Value ($vcvm|?{$_.Guest.GuestFamily -eq "windowsGuest"}).Count

            $output|Add-Member -MemberType NoteProperty -Name 'Datacenter' -Value $dc.Name

            $output|Add-Member -MemberType NoteProperty -Name 'Clusters in Datacenter' -Value $clusters.Count

            $output|Add-Member -MemberType NoteProperty -Name 'vDS in datacenter' -Value $vDS.name

            $output|Add-Member -MemberType NoteProperty -Name 'Total ESXi in Datacenter' -Value $dcvmhost.count

            $output|Add-Member -MemberType NoteProperty -Name 'Cluster' -Value $cl.Name

            $output|Add-Member -MemberType NoteProperty -Name 'Windows VM Count' -Value ($vm|?{$_.Guest.GuestFamily -eq "windowsGuest"}).Count

            $output|Add-Member -MemberType NoteProperty -Name 'No of ESXi in Cluster' -Value $vmhost.count

        

            Write-Progress -Activity "Collecting Datacenter Stats" -PercentComplete ($i/$global:defaultviservers.count * 100)

        

        

            $report += $output

        }

    }

}

$report|Out-GridView  

disconnect-viserver "*" -force -confirm:$false

0 Kudos
LucD
Leadership
Leadership
Jump to solution

I'm afraid I'm not sure how you want to integrate that info into this report.

That report's inner loop is over the clusters in a datacenter, while the storage device info is obtained per ESXi node.

How do you propose to add that information into the report?

Perhaps I'm not getting your idea, but perhaps you could show a mock up of the report you intend to create?


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

0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

You are right .we need to create one more loop at esxi level to get this info .

however what i was thinking to put is main storage make and model which is providing storage @ cluster and dc level .(not one to one datastore and storge model make)

but for the time being it is fine we can skip that.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

What would be the header of the report you envisage?

Can you produce a mock up?


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

0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

well the plan was to develop report using powercli and understand basic reporting mechanism .I belive this is how tools are evolved like RV tools.

the one which is there in current report is sufficient for time being .however as need arises we can add more into it.

iam using out-grid to display report .do yu suggest any other way to present like converto-html?

0 Kudos
LucD
Leadership
Leadership
Jump to solution

It's good that you mention RVTools.

That tool also has several tabs for different information, because some of that information is hard to combine in one report.

It would cause a lot of redundant data in the report.

Html is of course an option, and you can send that as a mail body or attachments.

What I normally do is to send my reports as separate worksheets in one XLSX file.

The ImportExcel module is a great tool for that.


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

0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

Thanks iam checking that .could you tell if vrops  is also using  powershell (powercli )in background  to generate reports.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Afaik vrops is using Javascript internally, but you can use PowerCLI to connect (Connect-OMServer).

And from there consume vrops functionality, see Sample Scripts for Managing vRealize Operations Manager with VMware PowerCLI

And there is also the PowerVRO module.

Jonathan did a series of posts on working with PowerVRO module.


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

0 Kudos