This improvement allows us to prioritize the access to the delivery controllers via PowerShell based on the Active Directory site of the worker server and the delivery controller. That way we solve the issues related to data replication between the AD sites when creating the new VM accounts.
How to recover the AD Site for each VM
To perform this prioritization, we need to know the AD Site where all the Delivery Controllers and the worker servers from which we will access the Delivery Controllers via powershell, are located.
This information can be found in the following registry key:
For the worker servers, it is reconmmended to access this value directly every time this value is required(i.e. when initializing the powershell scripts).
For the Delivery Controllers, in every Synchronize Infrastructure Job, when the nodes list of the Delivery Controller is updated, we should access the registry key remotely and get its value.
This value will be saved at Desktop Broker farm node level where a new column called "AD Site" will be created.
In case the registry key doesn´t exist, the same functionality we already know so far will be kept, and it will be assumed that we won´t work with AD sites.
If we have issues to get the Site Name from a VM remotely due to connection problems, we can edit the values in the AD Site column to access
another site. To do this, just click on the AD Site Name and edit the "AD Site" field in the Desktop broker node window.
After saving the change, the new site will be used in the synchronization process at some point.
Selecting the Delivery Controller
So far, in order to select the delivery controller where we have to execute the powershell scripts, we used the node list without taking into account any type of sorting(by default, it was sorted only by following the order in which the records were inserted) and then started testing the connection for each node one by one until we got a node to which we could connect with no issues.
But now the delivery controllers list should be sorted out based on the below conditions:
1- If the current worker server is included in a AD Site (where the registry key's value matches the name of the "AD-Site"), and the name of any of the nodes included in the mentioned AD Site matches the value included in the "First Node" field, such node will be the first one in the list.
2- If the current worker server is included in a AD Site (where the registry key's value matches the name of the "AD-Site"), the rest of the desktop broker farm nodes included in the mentioned AD Site will be added to the list.
3- Whether the worker server is included in a AD Site or not, the first node to be added to the list will be the one whose name is included in the "First Node" field included in the desktop broker farm(if and only if this node has not already been added to such list).
4- Finally, the rest of delivery controllers will be added to the list without following any order.