To dump the raw list of user profiles on a machine, use the following line:

Get-CimInstance -Class Win32_UserProfile | Out-GridView

You will get detailed information about all user profiles. The user name can be found in the property SID, however it is in SID format. To get the real user name, the SID would need to be translated. This chunk of code produces a hash table that uses the real user names as key:

$userProfiles = Get-CimInstance -Class Win32_UserProfile |
  # add property "UserName" that translates SID to username
  Add-Member -MemberType ScriptProperty -Name UserName -Value { 
    ([Security.Principal.SecurityIdentifier]$this.SID).Translate([Security.Principal.NTAccount]).Value
  } -PassThru |
  # create a hash table that uses "Username" as key
  Group-Object -Property UserName -AsHashTable -AsString

You can now easily dump the list of users that have a user profile on that machine:

 
PS C:\> $userProfiles.Keys | Sort-Object
MYDOMAIN\Administrator
MYDOMAIN\User01
MYDOMAIN\User02
MYDOMAIN\User03
MYDOMAIN\User12
NT AUTHORITY\LOCAL SERVICE
NT AUTHORITY\NETWORK SERVICE
NT AUTHORITY\SYSTEM
PC10\User
 

To get detailed info on a particular user profile, access the entry in the hash table:

 
PS C:\> $userProfiles["MYDOMAIN\User01"]


UserName                         : MYDOMAIN\User01
AppDataRoaming                   : Win32_FolderRedirectionHealth
Contacts                         : Win32_FolderRedirectionHealth
Desktop                          : Win32_FolderRedirectionHealth
Documents                        : Win32_FolderRedirectionHealth
Downloads                        : Win32_FolderRedirectionHealth
Favorites                        : Win32_FolderRedirectionHealth
HealthStatus                     : 3
LastAttemptedProfileDownloadTime : 
LastAttemptedProfileUploadTime   : 
LastBackgroundRegistryUploadTime : 
LastDownloadTime                 : 
LastUploadTime                   : 
LastUseTime                      : 
Links                            : Win32_FolderRedirectionHealth
Loaded                           : False
LocalPath                        : C:\Users\User01
Music                            : Win32_FolderRedirectionHealth
Pictures                         : Win32_FolderRedirectionHealth
RefCount                         : 
RoamingConfigured                : False
RoamingPath                      : 
RoamingPreference                : 
SavedGames                       : Win32_FolderRedirectionHealth
Searches                         : Win32_FolderRedirectionHealth
SID                              : S-1-5-21-3860347202-3037956370-3782488958-1604
Special                          : False
StartMenu                        : Win32_FolderRedirectionHealth
Status                           : 0
Videos                           : Win32_FolderRedirectionHealth
PSComputerName                   : 
 

Twitter This Tip! ReTweet this Tip!

Anonymous