On an internal mailing list someone asked how to get the SID for the current context using PowerShell. Chris Bellée correctly responded:
([Security.Principal.WindowsIdentity]::GetCurrent()).user.accountdomainsid.value
I used this to create a script: Get-Me.ps1
# Get-Me.ps1
[Security.Principal.WindowsIdentity]::GetCurrent()
PS> .\get-me.ps1
AuthenticationType : NTLMImpersonationLevel : NoneIsAuthenticated : FalseIsGuest : FalseIsSystem : FalseIsAnonymous : FalseName : JPSLAP14\GuestOwner : S-1-5-21-2812635655-1585162248-3907382133-501User : S-1-5-21-2812635655-1585162248-3907382133-501Groups : {S-1-5-21-2812635655-1585162248-3907382133-513, S-1-1-0, S -1-5-32-546, S-1-5-32-545...}Token : 1128
Simple - Useful - PowerShell :-)
Jeffrey Snover [MSFT]Windows Management Partner ArchitectVisit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShellVisit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx