≡ Menu

Powershell: Script Get Windows User Profiles on Remote Computer

I recently came across a requirement to list the User profiles in remote computer. I can do a quick dir of \\pc1\c$\users to get the list of profiles but that is not efficient. It is quite possible that profiles are placed in different drive/directory. After some research, I stumbled on a WMI class WIn32_UserProfile using which I can get the profiles list I wanted. I read about this class and what it can offer. Interestingly, I can get more details about a profile with this class. I can check if a profile is local, roaming, temporary, random or a corrupted one. This data is useful various scenarios. Also I can check if a profile is a human profile or it belongs to system (that means system is maintaining it — ex: networkservice).

So, the script discussed in this article will help you to get list of user profiles on remote computer and what type of profile it is, profile path (where the profile is stored), and will tell you if the profile is non-system profile or system profile.

One thing I must note here is, Win32_UserProfile WMI class is available in systems greater than Windows Vista/Windows 2008. The previous Operating Systems are not having this class. It means that script will not work for any computers having prior operating systems like Windows 2003/2000/XP, etc.

Script : Get-UserProfile.ps1

param (
[string[]]$ComputerName = $env:computername,

foreach ($Computer in $ComputerName) {
 $Profiles = Get-WmiObject -Class Win32_UserProfile -Computer $Computer -ea 0
 foreach ($profile in $profiles) {
  $objSID = New-Object System.Security.Principal.SecurityIdentifier($profile.sid)
  $objuser = $objsid.Translate([System.Security.Principal.NTAccount])
  switch($status.Status) {
   1 { $profileType="Temporary" }
   2 { $profileType="Roaming" }
   4 { $profileType="Mandatory" }
   8 { $profileType="Corrupted" }
   default { $profileType = "LOCAL" }
  $User = $objUser.Value
  $ProfileLastUseTime = ([WMI]"").Converttodatetime($profile.lastusetime)
  $OutputObj = New-Object -TypeName PSobject
  $OutputObj | Add-Member -MemberType NoteProperty -Name ComputerName -Value $Computer.toUpper()
  $OutputObj | Add-Member -MemberType NoteProperty -Name ProfileName -Value $objuser.value
  $OutputObj | Add-Member -MemberType NoteProperty -Name ProfilePath -Value $profile.localpath
  $OutputObj | Add-Member -MemberType NoteProperty -Name ProfileType -Value $ProfileType
  $OutputObj | Add-Member -MemberType NoteProperty -Name IsinUse -Value $profile.loaded
  $OutputObj | Add-Member -MemberType NoteProperty -Name IsSystemAccount -Value $profile.special
  if($UserName) {
   if($User -match $UserName) {
  } else {



By default the script gets you all profiles in the computer. If you are looking for the details of a specific profile, just use the -UserName Parameter. For example, to get the profile of LocalUser1, use .\Get-UserProfiles.ps1 -UserName localuser1

Similarly to get the profiles on remote computer, use -ComputerName parameter. See below image for examples.

In my next post I will write about how to delete windows user profiles using powershell script and Win32_UserProfile WMI class.

Comments on this entry are closed.

  • Johannes Sebald January 14, 2014, 8:18 pm

    Really a very good and especially helpful post! The script looks solid and I have to use it for various problem cases. Thank you Sitaram Pamarthi.

  • Manvin June 10, 2014, 8:43 pm

    can i get the script to delete user profile on the 2008 serverlocal or remote along with the sid delete in the registry with errorhandling.

    Thank’s in advance

  • dean November 26, 2015, 9:38 am

    switch($status) {

    or switch($profile.status) {

    • TechiBee February 7, 2016, 4:25 pm

      Dean, thanks for highlighting it. Corrected it to $Profile.Status

  • Chris February 24, 2016, 8:43 pm

    Is there a way to get the size of the profile folder in this script?

  • Greg July 15, 2016, 12:17 am

    Great script! Is there a way to validate the results against Active Directory active user accounts?

  • Alfred Kuhnert January 23, 2018, 9:31 pm

    FYI: I had to remove ($profile.lastusetime) from the line:
    $ProfileLastUseTime = ([WMI]””).Converttodatetime($profile.lastusetime)

    to stop an error from occurring on my Win7 PCs.

    Thanks for the script. I am using it to display SIDs for users on a PC.