Header Ads

recent

Who am I?

if you'd like to know your current user account, UserDomain of course you can query environment variables like this:
PS C:\> $env:userdomain
Admin-PC

PS C:\> $env:username
admin

You get a lot more information including your security identifier (SID) by using the appropriate .NET methods:

PS C:\> [System.Security.Principal.WindowsIdentity]::GetCurrent()


AuthenticationType : NTLM
ImpersonationLevel : None
IsAuthenticated    : True
IsGuest            : False
IsSystem           : False
IsAnonymous        : False
Name               : Admin-PC\admin
Owner              : S-1-5-21-981951286-3924174524-3344100332-1000
User               : S-1-5-21-981951286-3924174524-3344100332-1000
Groups             : {S-1-5-21-981951286-3924174524-3344100332-513, S-1-1-0, S-1-5-32-545, S-1-5-4...}
Token              : 644
UserClaims         : {http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name: Admin-PC\admin,
                     http://schemas.microsoft.com/ws/2008/06/identity/claims/primarysid:
                     S-1-5-21-981951286-3924174524-3344100332-1000,
                     http://schemas.microsoft.com/ws/2008/06/identity/claims/primarygroupsid:
                     S-1-5-21-981951286-3924174524-3344100332-513, http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid:
                     S-1-5-21-981951286-3924174524-3344100332-513...}
DeviceClaims       : {}
Claims             : {http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name: Admin-PC\admin,
                     http://schemas.microsoft.com/ws/2008/06/identity/claims/primarysid:
                     S-1-5-21-981951286-3924174524-3344100332-1000,
                     http://schemas.microsoft.com/ws/2008/06/identity/claims/primarygroupsid:
                     S-1-5-21-981951286-3924174524-3344100332-513, http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid:
                     S-1-5-21-981951286-3924174524-3344100332-513...}
Actor              :
BootstrapContext   :
Label              :
NameClaimType      : http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name
RoleClaimType      : http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid

PS C:\> [System.Security.Principal.WindowsIdentity]::GetCurrent() |
 Select-Object -ExpandProperty Name
Admin-PC\admin
PS C:\> [System.Security.Principal.WindowsIdentity]::GetCurrent() |
 Select-Object -ExpandProperty User

                                BinaryLength AccountDomainSid                             Value                                     
                                ------------ ----------------                             -----                                     
                                          28 S-1-5-21-981951286-3924174524-3344100332     S-1-5-21-981951286-3924174524-3344100332...


PS C:\> [System.Security.Principal.WindowsIdentity]::GetCurrent() |
 Select-Object -ExpandProperty Groups

                                BinaryLength AccountDomainSid                             Value                                     
                                ------------ ----------------                             -----                                     
                                          28 S-1-5-21-981951286-3924174524-3344100332     S-1-5-21-981951286-3924174524-3344100332...
                                          12                                              S-1-1-0                                   
                                          16                                              S-1-5-32-545                               
                                          12                                              S-1-5-4                                   
                                          12                                              S-1-2-1                                    
                                          12                                              S-1-5-11                                  
                                          12                                              S-1-5-15                                  
                                          12                                              S-1-2-0                                   
                                          16                                              S-1-5-64-10            


No comments:

Systemadminworld. Powered by Blogger.