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

3

1

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

Posted 2016-09-01T16:26:38.177

Reputation: 242

This SU question may offer some help: How to know SID of Windows' user account?

– Ƭᴇcʜιᴇ007 – 2016-09-01T17:29:07.280

Answers

1

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

Access type: Read-only

Gets a bit field that contains the status of the profile.


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

Pimp Juice IT

Posted 2016-09-01T16:26:38.177

Reputation: 29 425

1

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

lightwing

Posted 2016-09-01T16:26:38.177

Reputation: 83

powershell.exe -command "gwmi win32_userprofile | select localpath,roamingpath,status" displays only the list of local paths – DannyBoi – 2016-09-02T10:56:41.223

I'm not sure. I tested it on my own system to a server like this: psexec \\servername powershell -command "gwmi win32_userprofile | select localpath,roamingpath,status" It returned the results expected for me. Is it possible there are no roaming profiles on your device? If there are no roaming profiles, the roaming profile column will be empty and status will be something other than 2 (0 if its local). – lightwing – 2016-09-02T12:42:22.453

Try this. It will confirm whether those fields exist within that WMI class on the system you're testing: psexec \\servername powershell.exe -command "gwmi win32_userprofile | get-member"' Get-member returns a list of all the properties and methods available for the command that is piped to it. – lightwing – 2016-09-02T12:49:57.143

So I did get-member and Localpath , Roaming Path , Status are all there. I ran the command piecewise from cmd. powershell then gwmi then win32_userprofile' it displays all the info includingLocalpath , Roaming Path , Status` . Roaming path is blank however status is fine. – DannyBoi – 2016-09-02T20:26:54.680

@ltghtwing..... I tried powershell.exe -command "gwmi win32_userprofile | select status" It all came blank. Then I copied it to a text file and found that the status column is displaying on column 445 . We need a better filter – DannyBoi – 2016-09-02T20:33:28.037