VMware Cloud Community
MD_Mo
Contributor
Contributor

Speed up Setting custom attributes with Start-Job

Is there are way to create start-jobs for setting custom attributes. I just started reading about and looking to speed a script. I have about 20k servers that I need to set the attributes for. Here my regular script.

Connect-VIServer $vCenters

$pathDev = "C:\Powershell\vCenter\Tags\VMs"

Set-Location $pathDev

$CSV = Import-Csv .\VMsAttributes.csv

foreach ($line in $CSV)

{

Set-Annotation -CustomAttribute "Project" -Entity $line.Name -Value $line."Project"

Set-Annotation -CustomAttribute "Applications Owners" -Entity $line.Name -Value $line."Applications Owners"

Set-Annotation -CustomAttribute "Responsible Organization" -Entity $line.Name -Value $line."Responsible Organization"

Set-Annotation -CustomAttribute "Systen Administrators DL" -Entity $line.Name -Value $line."Systen Administrators DL"

}


Disconnect-VIServer $vCenters -Confirm:$False

Reply
0 Kudos
1 Reply
LucD
Leadership
Leadership

You can use background jobs to split the work.
See my Running a background job dive for some of the peculiarities of using PowerCLI in such a background job.

You will have to split the workload. You can pass a subset of the VMs to each background job.

You could do that by cluster, or by a range of VM based on their name...

Your choice.

Be also aware that there is a limit to the number of background jobs you can start in parallel on a station.

This depends on the amount of available memory, CPU resources ....

Also be aware that there will be a load on your vCenter when you launch multiple background jobs in parallel.

Determining the ideal number of background jobs is partially trial-and-error and partially common sense


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

Reply
0 Kudos