Automation

 View Only
Expand all | Collapse all

Script for Resource pool

  • 1.  Script for Resource pool

    Posted Apr 18, 2017 10:54 AM

    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.



  • 2.  RE: Script for Resource pool

    Posted Apr 18, 2017 11:03 AM

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

    That contais quite a bit of Resourcepool details.



  • 3.  RE: Script for Resource pool

    Posted Apr 18, 2017 02:49 PM

    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.



  • 4.  RE: Script for Resource pool

    Posted Apr 18, 2017 05:04 PM

    Try something like this

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

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



  • 5.  RE: Script for Resource pool

    Posted Apr 19, 2017 06:39 AM

    Great Script... Thanks a lot...



  • 6.  RE: Script for Resource pool

    Posted Apr 19, 2017 05:13 PM

    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



  • 7.  RE: Script for Resource pool

    Posted Apr 19, 2017 04:18 AM

    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.



  • 8.  RE: Script for Resource pool

    Posted Apr 19, 2017 05:03 AM

    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



  • 9.  RE: Script for Resource pool

    Posted Apr 19, 2017 05:25 AM

    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.



  • 10.  RE: Script for Resource pool

    Posted Apr 19, 2017 05:46 AM

    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



  • 11.  RE: Script for Resource pool

    Posted Apr 19, 2017 06:29 AM

    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



  • 12.  RE: Script for Resource pool

    Posted Apr 19, 2017 05:55 PM

    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...



  • 13.  RE: Script for Resource pool

    Posted Apr 21, 2017 03:52 PM

    Hi LuCD,

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

    Thanks in advance.



  • 14.  RE: Script for Resource pool

    Posted Apr 24, 2017 12:01 PM

    Hi LucD,

    Can you able to help on this?

    Thanks in advance.



  • 15.  RE: Script for Resource pool

    Posted Apr 24, 2017 12:38 PM

    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



  • 16.  RE: Script for Resource pool

    Posted Apr 25, 2017 09:30 AM

    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.



  • 17.  RE: Script for Resource pool

    Posted Apr 25, 2017 09:33 AM

    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.



  • 18.  RE: Script for Resource pool

    Posted Apr 25, 2017 11:21 AM

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



  • 19.  RE: Script for Resource pool

    Posted Apr 25, 2017 11:32 AM

    Hi LuCD,

    Yes, Comparison is happening now.

    Thanks in advance.