I got a request from a system owner what was the SID of the domain since their license was bound to the domain SID. The Domain SID is not really that is going to change and its really unlikely that anyone will collide with yours, so not really a bad choice.

Anyways if you have the Active Directory Powershell module its really easy to do this. Without the AD Powershell module its not really that hard either, but Im lazy when the three latest published versions of Windows has the modules available I feel that I can skip doing it the long way.

Lets continue with the show:

Import-Module ActiveDirectory
PS C:\Users\virot> (Get-ADForest).Domains| %{Get-ADDomain -Server $_}|select name, domainsid
 
name                                                                          domainsid
----                                                                          ---------
test                                                                          S-1-5-21-15748454-485475757-1574545454
subdomain                                                                     S-1-5-21-4545185484-4581287845-1575484548
another                                                                       S-1-5-21-1112151888-844548645-148348348
And there we go, easy as 1-2-3