Get SID by Powershell for SharePoint

You can use following powershell to check SID from AD.

$NTAccount = new-object System.Security.Principal.NTAccount(‘SamAccountName’)
$TranslatedToSidObject = $NTAccount.Translate( [System.Security.Principal.SecurityIdentifier])
$SID = New-Object System.Security.Principal.SecurityIdentifier($TranslatedToSidObject.Value)
$TranslatedToNTAccount = $SID.Translate([System.Security.Principal.NTAccount])
Write-host $TranslatedToSidObject.Value `t`t $TranslatedToNTAccount.Value

You can use following powershell to check SID in SharePoint

$site = get-spsite http://blog.bugrapostaci.com
$web = $site.OpenWeb()
$user = $web.EnsureUser(“BLOG\bugra”)
$user.Sid

 

Advertisements