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.
SID
Version 1.0.6
Created on 2016-04-14
Modified on 2017-01-31
Created by Tony McBride
Downloads: 589

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$)"