4

How to check, from cmd, if a profile status is local or temp or roaming or backup ?

I there a way we can check the TYPE and STATUS of the profiles in the computer from the command line.

Normally we get it here....

System properties

I will connect to the computer using psexec \\ipaddress cmd Then I want to run a command to view this info.

I could check it in the registry by analyzing the PROFILE IMAGE PATH but for that, I have to find the SID first. But this method is not perfect because it tells me only whether it is local or not.

I would prefer a command line method to check the Profile Size , Type and Status. 'Status' being the priority in this question. I want to distinguish the profile status distinctly whether it is local or roaming or temporary or backup.

Please help.

DannyBoi
  • 262

2 Answers2

2

You can query WMI through Powershell using psexec with this command:

powershell.exe -command "gwmi win32_userprofile | select localpath,roamingpath,status"

localpath with give you the username and status will give you the type.

Win32_UserProfile class

Status values:

  • Undefined - 0 - The status of the profile is not set.
  • Temporary - 1 - The profile is a temporary profile and will be deleted after the user logs off.
  • Roaming - 2 - The profile is set to roaming. If this bit is not set, the profile is set to local.
  • Mandatory - 4 - The profile is a mandatory profile.
  • Corrupted - 8 - The profile is corrupted and is not in use. The user or administrator must fix the corruption to use the profile.

If you can psexec though, you could probably just use the powershell gwmi command switch to hit the device remotely:

gwmi win32_userprofile -computername mypc | select localpath,roamingpath,status

Also, to address the profile size request, this may help: Hey Scripting Guy Blog: Use PowerShell to Find Size of User Profile

2

How to check, from cmd, if a profile status is local or temp or roaming or backup?

Here's the pure command line straight WMIC method to get the Status based on the LocalPath value of the Username you want to check.

Be sure the %username% value of the profile to check is explicitly put in place of %username% if it's not to check the profile you're running it from when you run it.

The Command

WMIC PATH win32_UserProfile WHERE LocalPath="c:\\users\\%username%" GET Status

Result Example

enter image description here


Status Value Meanings

Status

Data type: uint32

<p>Access type: Read-only</p>

<p>Gets a bit field that contains the status of the profile.</p>

This property contains one or more of the following values:

  • Value: 0 Undefined
    • Meaning: The status of the profile is not set.

  • Value: 1 Temporary
    • Meaning: The profile is a temporary profile and will be deleted after the user logs off.

  • Value: 2 Roaming
    • Meaning: The profile is set to roaming. If this bit is not set, the profile is set to local.

  • Value: 4 Mandatory
    • Meaning: The profile is a mandatory profile.

  • Value: 8 Corrupted
    • Meaning: The profile is corrupted and is not in use. The user or administrator must fix the corruption to use the profile.

source


Further Resources