Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 175326

PowerCLI VMware Host Tag help Needed

$
0
0

Hi Guys,

 

I have a script for collecting the necessary information that i need about ESX hosts. The script was very fast, and runs in few minutes to get data from many vCenters. Now i wanted to include Tag information of ESX host in my output. This tag is to indicate ownership of the host. I added 'Get-TagAssignment -Entity $_.Name' to my script and hoped it will do the job, But all of a sudden the script became extremely slow, and takes hours to pull just from one VC. We have a mix of 5.5 and 6.0 VCs and hosts. I know that in 5.5, tags have to be retrieved from inventory service., which might be slowing this down. Also i am not able to find a hostsystem property for Tag, that i can include with get-view. I guess this is again due to the fact that it is stored in inventory service and not in vcenter server. Can you please help me here, and find a faster way to get the info. Thanks in advance!

 

$vcenter = vcenter1

connect-viserver $vcenter

Get-View -ViewType HostSystem -Property Name,Parent,Runtime.ConnectionState,Config.Product,Hardware,VM -Server $vcenter | %{

        $obj = [ordered]@{

            vCenter = $vcenter

            Hostname = $_.Name

            Ownership = Get-TagAssignment -Entity $_.Name

            Cluster = &{

                $parent = Get-View -Id $_.Parent -Property Name,Parent

                while($parent -isnot [VMware.Vim.ClusterComputeResource] -and $parent -isnot [VMware.Vim.Datacenter]){

                    $parent = Get-View -Id $parent.Parent -Property Name,Parent

                }

                if($parent -is [VMware.Vim.Datacenter]){

                    ''

                    $script:sa = 'Yes'

                }

                else{

                    $parent.Name

                    $script:sa = 'No'

                }

            }

            Stand_Alone = $script:sa

            State = $_.runtime.connectionState

            ESX_Version =$_.config.product.version

            Build =$_.config.product.build

            Model =$_.hardware.systemInfo.model

            CPU_Sockets =$_.hardware.CpuInfo.numCpuPackages

            CPU_Cores =$_.hardware.CpuInfo.numCpuCores

            RAM_GB = [math]::Round((($_.hardware.memorySize)/(1GB)),1)

            VM = $_.vm.Count

        }

        $HostReport += New-Object PSObject -Property $obj

    }

 

Thanks,

VJ


Viewing all articles
Browse latest Browse all 175326

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>