Automation

 View Only
  • 1.  Get-TagAssignment is very slow

    Posted Mar 27, 2019 06:04 AM

    How to accelerate work of the command Get-TagAssignment

    Since at increase in number of required tags time increases multiply

    simple script for test

    $LOGFile = "C:\Reports\=VM-info-CPUlevel.csv"

    $LOG = New-Object PSObject

    Add-Member -InputObject $LOG -MemberType NoteProperty -Name VMname -Value "VM name"

    Add-Member -InputObject $LOG -MemberType NoteProperty -Name OS -Value "VM OS"

    Add-Member -InputObject $LOG -MemberType NoteProperty -Name vCPU -Value "vCPU"

    Add-Member -InputObject $LOG -MemberType NoteProperty -Name vMEM -Value "vMEM"

    Add-Member -InputObject $LOG -MemberType NoteProperty -Name VMtag -Value "CPUlevel"

    Add-Member -InputObject $LOG -MemberType NoteProperty -Name ESX -Value "ESXi"

    $VMs = get-vm

    $Currenttime = get-date -format "HH:mm:ss"

    Write-Host "Start - "$Currenttime -ForegroundColor Magenta

    Write-Host "Total VMs - "$VMs.count -ForegroundColor Cyan

    foreach ($VM in $VMs)

        {

            # $VM = $VMs

            $LOG.ESX = $VM.VMHost.name

            $VMinfo = $VM

            $LOG.VMname  = $VM.name

            $LOG.OS  = $VMinfo.Guest.OSFullName

            $LOG.vCPU  = $VMinfo.NumCpu

            $LOG.vMEM = $VMinfo.MemoryGB

           

            # get tag

            $LOG.VMtag = ($VM | Get-TagAssignment –Category "CPUlevel").Tag.name

            Export-Csv -path $LOGFile  -InputObject $LOG -Encoding UTF8 -Append

            $LOG.VMname  = $VM.name

            $LOG.OS  = $null

            $LOG.vCPU  = $null

            $LOG.vMEM = $null

            $LOG.VMtag = $null

        }

    $Currenttime = get-date -format "HH:mm:ss"

    Write-Host "Stop - "$Currenttime -ForegroundColor yellow

    Performance of a simple script without inquiry of a tag makes 3 seconds.

    Performance of a simple script from inquiry of a tag makes the 5 minutes and 2 seconds.



  • 2.  RE: Get-TagAssignment is very slow

    Posted Mar 27, 2019 07:58 AM

    Yes, especially the TagAssignment cmdlets are rather slow.

    As an alternative, try the functions in the VMware.Community.CISTag module.

    They are definitely faster.



  • 3.  RE: Get-TagAssignment is very slow

    Posted Mar 27, 2019 12:16 PM

    Unfortunately Get-CISTagAssignment not such fast as I expected

    VMware support refused the solution of a question since SDK Support is not bought

    But encouraged that the problem will be solved in 6.5U3 and 6.7U2



  • 4.  RE: Get-TagAssignment is very slow

    Posted Mar 27, 2019 12:23 PM

    Nice to hear a solution is coming.

    Btw, that refusal to answer your SR is not entirely correct.
    See PowerCLI Support Breakdown, where it clearly says in the Summary "VMware PowerCLI is supported by VMware and support requests can be opened! VMware supports both the installation process and cmdlet usage."

    And you don't need a Developer Support Contract for that.