<< Back to Script Library

Find Computer and Domain SID

This script will query the SID used by the computer as well as the domain object SID used by Active Directory and return the output for both.
For the local SID that the computer uses for itself, this is the same as the SID for the local Administrator without the -500 on the end.
For the Domain Object SID, this is queried from Attribute editor of the Computer object in AD.
Version: 1.0.6
Created: 2016-04-14
Modified: 2017-01-31
Creator: Tony McBride
Downloads: 555
Tags: SID
The Script Copy Script Copied to clipboard
$hostname = $args[0]

function get-sid
{
    Param ( $DSIdentity )
    $ID = new-object System.Security.Principal.NTAccount($DSIdentity)
    return $ID.Translate( [System.Security.Principal.SecurityIdentifier] ).toString()
}
$admin = get-sid "Administrator"

Write-Output "Computer SID = $($admin.SubString(0, $admin.Length - 4))"
Write-Output "Domain SID = $(get-sid $hostname$)"