«

»

Feb 06 2017

Print this Post

Orchestrator Runbook: Select Domain Controller with Minimum PS Sessions

Many of the Runbooks I have connect to domain controller to perform an activity using a PowerShell script, and usually this means multiple instance of the Runbook may be running at the same time.

These Runbooks require the FQDN of the domain controller to work on. Two challenges lie there,

  1. Load balancing: I want to ensure I do not try to connect to a domain controller that is already busy handling other remote sessions while others are idling.
  2. Availability: Hardcoding the FQDN of one domain controller means if it is down the Runbook will fail.

Therefore, I created a Runbook that checks for available DCs in the Runbook Server’s site and returns the FQDN of the DC with the least number of active remote sessions. If more than one DC has the least number of sessions, it return a random one.

I included a link to download the Runbook at the end of this post.

Flowchart of PowerShell script

 

PowerShell script

The PowerShell Script works on x86 PowerShell so we do not need to open a remote session to the localhost.

 

Runbook

Below is a screenshot of the Runbook.

Finally, you can download the Runbook from this link.

Cheers!

About the author

Walid AlMoselhy

Permanent link to this article: http://almoselhy.azurewebsites.net/2017/02/orchestrator-runbook-select-domain-controller/

Leave a Reply

Your email address will not be published. Required fields are marked *