Welcome to MSDN Blogs Sign in | Join | Help

Get-Me.ps1

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 : NTLM
ImpersonationLevel : None
IsAuthenticated    : False
IsGuest            : False
IsSystem           : False
IsAnonymous        : False
Name               : JPSLAP14\Guest
Owner              : S-1-5-21-2812635655-1585162248-3907382133-501
User               : S-1-5-21-2812635655-1585162248-3907382133-501
Groups             : {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 Architect
Visit the Windows PowerShell Team blog at:    http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at:  http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

Published Tuesday, December 02, 2008 4:30 PM by PowerShellTeam
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Get-Everyone

Jeffery Snover just posted a Get-Me script .  The Get-Me script finds out the principal of the user

Tuesday, December 02, 2008 4:04 PM by Windows PowerShell Blog

# Declare-Slacker

What, no friendly names for your SIDs?  Slacker!  *grin*

Tuesday, December 02, 2008 9:34 PM by Bruce Williams [MSFT]

# re: Get-Me.ps1

The difference between this command and $NTIdentity would be?

Thursday, December 11, 2008 1:10 AM by rferrisx

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker