Dynamic limit on scripting?
I need to make a script to install on 500+ machines. But, I need to limit it to run on no more than 10 machines at a time and with a gap of ten minutes between runs to avoid overloading. Short of having to make multiple copies of a script with labels containing 10 machines and then a staggered installed, is there a way to tell the SMA to only run ten at a time and then delay?
Has anyone done anything like this?
Answers (2)
You can do this with the API calls (as mentioned in https://www.itninja.com/question/where-to-find-information-on-exporting-kace-inventory-information-to-other-data-applications).
You would be able to script something that gets a list of Machine IDs
Then does a foreach where it does x (10?) then waits a set amount of time before continuing.
Connect-SmaServer -Server $KBOX -Org $Org -Credential $Cred -Verbose;Invoke-SMAScript -ScriptID [SCRIPT ID] -TargetMachineID [MACHINE ID] | Tee-Object -Variable RunTask
This returns a RunId for the script.
You could do one at a time and do a while loop where it checks the status and while success and failure are both $null continue. Just have it get the results and check, if not done then wait x seconds and repeat.
Connect-SmaServer -Server $KBOX -Org $Org -Credential $Cred -Verbose;Get-SmaScriptRunStatus -Id [SCRIPT RUNID] | Tee-Object -Variable RunResult