GetLocalGroupsSID

$computerName = Read-Host ‘Enter computer name or press <Enter> for localhost’

$List = @{}

if ($computerName -eq “”) {$computerName = “$env:computername”}

$computer = [ADSI]”WinNT://$computerName,computer”

$Users = $computer.psbase.Children | Where-Object { $_.psbase.schemaclassname -eq ‘group’ }

foreach ($i in $Users)

{$objUser = New-Object System.Security.Principal.NTAccount($i.Name)

$strSID = $objUser.Translate([System.Security.Principal.SecurityIdentifier])

$list[$i.Name[0]] = $strSid.Value

}

$list | ft


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *