Quantcast
Channel: Système informatique, sécurité et Web
Viewing all articles
Browse latest Browse all 187

Token size: PowerShell script tro read his own token

$
0
0

##############################################

# Script to read his own token

##############################################

 

$token = [System.Security.Principal.WindowsIdentity]::GetCurrent()

$token

 

# nb de groupes

$token.groups.count

 

$groupSIDS = $token.Groups

$groupSIDs[10]

 

$token = [System.Security.Principal.WindowsIdentity]::GetCurrent() # Get current user context

$groupSIDs = $token.Groups # Get SIDs in current Kerberos token

foreach($sid in $groupSIDs) { # for each of those SIDs…

try { # try to..

Write-Host (($sid).Translate([System.Security.Principal.NTAccount])) # translate the SID to an account name

}

catch { # if we can’t translate it…

Write-Warning (« Could not translate  » + $sid.Value + « . Reason:  » + $_.Exception.Message) # Output a warning and the corresponding exception

}

}


Viewing all articles
Browse latest Browse all 187

Trending Articles