VMware Cloud Community
Vel_VMware
Enthusiast
Enthusiast

Script for Resource pool

Hi,

Can any one please help me providing script for getting number of resource pool details and count of associated VM's running on it in vCenter.

Excluding default resource pool.

Thanks in advance.

18 Replies
LucD
Leadership
Leadership

Have you already looked at 4.  Re: Cluster and Resourcepool allocation report

That contais quite a bit of Resourcepool details.


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

Vel_VMware
Enthusiast
Enthusiast

Hi LucD,

Its great script which has so many information and its taking much time to run.

Can you please help me only to get resource pool info from that script.

I would like to get below information,

Resource Pool Name,

Reservation detail CPU and memory

No VM's running on the respective resource pool and it power state

Thanks in advance.

0 Kudos
LucD
Leadership
Leadership

Try something like this

Get-ResourcePool | where{$_.Name -notmatch 'Resources'} |

Select Name,CpuReservationMHz,MemReservationGB,@{N='VMnr';E={$_.ExtensionData.VM.Count}}


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

Vel_VMware
Enthusiast
Enthusiast

Hi LucD,

Its great, It works.

Thanks a loooot...

Can you do one more favor, I am trying below script its giving NULL output.

Import-Module C:\Vi-Module.psm1

Get-Cluster SGD0001 |Get-VMHost | Compare-VMHostSoftwareVib -ReferenceVMHost (Get-VMHost 'esxd0013.*') | Export-Csv -NoTypeInformation -Path 'C:\Temp\Dharma\VibCompare.csv'

This has been used for VIB comparison by taking reference of one host in cluster.  But its not working.

Can you please help on this.

Thanks in advance.

0 Kudos
LucD
Leadership
Leadership

I don't know that module, but I suspect it might produce no output because there are no differences in the VIBs on the different ESXi nodes in the cluster.

The following similar function lists all VIBs, even if there is no difference

$clusterName = 'MyCluster'

$cluster = Get-Cluster -Name $clusterName

$refEsx = Get-VMHost -Location $cluster | Get-Random

$esxcli = Get-Esxcli -VMHost $refEsx

$refArray = $esxcli.software.vib.list()

$report = foreach($esx in (Get-VMHost -Location $cluster | where{$_.Name -ne $refEsx.Name})){

    $esxcli = Get-EsxCli -VMHost $esx

    Compare-Object -ReferenceObject $refArray -DifferenceObject ($esxcli.software.vib.list()) -IncludeEqual |

    Select @{N='Cluster';E={$clusterName}},

        @{N='RefEsx';E={$refEsx.Name}},

        @{N='Esx';E={$esx.Name}},

        @{N='Vib';E={$_.InputObject.Name}},

        @{N='VibVersion';E={$_.InputObject.Version}},

        @{N='Result';E={

            switch($_.SideIndicator){

                '==' {'Equal'}

                'Default' {'Different'}

            }

        }}

}

$report | ft -AutoSize


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

0 Kudos
Vel_VMware
Enthusiast
Enthusiast

Hi LucD,

It seems each and every time we need to give the cluster name in script. And, how its take reference host?

Can you make it to ask for cluster name and reference host from us, which we will give those inputs.

Also, I could see some hosts are not coming in output.

Thanks in advance.

0 Kudos
Vel_VMware
Enthusiast
Enthusiast

Hi LuCD,

Requesting one more change please,

Instead of cluster can you make it for entire cluster by taking one reference host which we will give input.

Whether can we get installed date for each VIB's on same script?

Thanks in advance

0 Kudos
Vel_VMware
Enthusiast
Enthusiast

Hi LuCD,

It seems script is not providing expected output, I have difference in tools-light vib version in two different host but its still showing equal.

Can you help me to checked it again. If possible to include the below columns.

Cluster,  REF host,  Installed VIB in REF host with version,  Installed Date, comparing ESX host name, Installed VIB in host with version, Installed date,  Equal/Not equal

0 Kudos
Vel_VMware
Enthusiast
Enthusiast

Great Script... Thanks a lot...

0 Kudos
LucD
Leadership
Leadership

I seem to be getting correct results from the compare.
Try like this, it contains the prompts and the extra properties

$clusterName = Read-Host -Prompt 'Cluster name:'

$cluster = Get-Cluster -Name $clusterName

$esx = Get-VMHost -Location $cluster

$i = 1

$esx | %{

    Write-Host "$($i): $($_.Name)"

    $i++

}

$esxRefNr = Read-Host -Prompt "Select Reference host (1-$($esx.Count))"

$refEsx = $esx[$esxRefNr-1]

$esxcli = Get-Esxcli -VMHost $refEsx

$refArray = $esxcli.software.vib.list()

$report = foreach($vmhost in ($esx | where{$_.Name -ne $refEsx.Name})){

    $esxcli = Get-EsxCli -VMHost $vmhost

    Compare-Object -ReferenceObject $refArray -DifferenceObject ($esxcli.software.vib.list()) -IncludeEqual |

    Select @{N='Cluster';E={$clusterName}},

        @{N='RefEsx';E={$refEsx.Name}},

        @{N='Esx';E={$vmhost.Name}},

        @{N='Vib';E={$_.InputObject.Name}},

        @{N='VibVersion';E={$_.InputObject.Version}},

        @{N='VibInstallDate';E={$_.InputObject.InstallDate}},

        @{N='Result';E={

            switch($_.SideIndicator){

                '==' {'Equal'}

                'Default' {'Different'}

            }

        }}

}

$report | ft -AutoSize


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

0 Kudos
Vel_VMware
Enthusiast
Enthusiast

Hi LuCD,

You are really great, script really good.

But only thing is comparison is not happening properly, As I said before I have different tools light vib version in two different host but it shows as "Equal".

Also I have same HBA drivers but it say "NULL", Can you please look into this.

I request you to two more fields in output "VIB version and installed in comparing host" as like which you already added reference host.

Really I would like to appreciate that you have done a excelletn job.

Thanks a lot...

0 Kudos
Vel_VMware
Enthusiast
Enthusiast

Hi LuCD,

Looking for your help.......!

Thanks in advance.

0 Kudos
Vel_VMware
Enthusiast
Enthusiast

Hi LucD,

Can you able to help on this?

Thanks in advance.

0 Kudos
LucD
Leadership
Leadership

The Switch block was incorrect, try like this (to see if it discovers the differences).

$clusterName = Read-Host -Prompt 'Cluster name:'

$cluster = Get-Cluster -Name $clusterName

$esx = Get-VMHost -Location $cluster

$i = 1

$esx | %{

    Write-Host "$($i): $($_.Name)"

    $i++

}

$esxRefNr = Read-Host -Prompt "Select Reference host (1-$($esx.Count))"

$refEsx = $esx[$esxRefNr-1]

$esxcli = Get-Esxcli -VMHost $refEsx

$refArray = $esxcli.software.vib.list()

$report = foreach($vmhost in ($esx | where{$_.Name -ne $refEsx.Name})){

    $esxcli = Get-EsxCli -VMHost $vmhost

    $swArray = $esxcli.software.vib.list()

    Compare-Object -ReferenceObject $refArray -DifferenceObject $swArray -IncludeEqual -Property Name,CreationDate,Vendor,Version |

    Select Name,Version,InstallDate,Vendor,@{N='Cluster';E={$clusterName}},

        @{N='RefEsx';E={$refEsx.Name}},

        @{N='Esx';E={$vmhost.Name}},

        @{N='Vib';E={$_.InputObject.Name}},

        @{N='VibVersion';E={$_.InputObject.Version}},

        @{N='VibInstallDate';E={$_.InputObject.InstallDate}},

        @{N='Result';E={

            switch($_.SideIndicator){

                '==' {'Equal'}

                Default {'Different'}

            }

        }}

}

$report | ft -AutoSize


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

0 Kudos
Vel_VMware
Enthusiast
Enthusiast

Hi LuCD,

It seems comparison happening, but I am not installed date for REF host and VIB version & installed date for target host.

Could you please help me to check that only,

Thanks in advance.

0 Kudos
Vel_VMware
Enthusiast
Enthusiast

Hi LuCD,

It seems comparison happening, but I am not getting installed date for REF host and VIB version & installed date for target host.

Could you please help me to check that only,

Thanks in advance.

0 Kudos
LucD
Leadership
Leadership

I know, just wanted to make sure the comparison was happening now.


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

0 Kudos
Vel_VMware
Enthusiast
Enthusiast

Hi LuCD,

Yes, Comparison is happening now.

Thanks in advance.

0 Kudos