How to check, from cmd, if a profile status is local or temp or roaming or backup?
Solution 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
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.
Further Resources
Solution 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.
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
DannyBoi
Updated on September 18, 2022Comments
-
DannyBoi almost 2 years
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....
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.
-
Ƭᴇcʜιᴇ007 almost 8 yearsThis SU question may offer some help: How to know SID of Windows' user account?
-
-
DannyBoi almost 8 years
powershell.exe -command "gwmi win32_userprofile | select localpath,roamingpath,status"
displays only the list of local paths -
lightwing almost 8 yearsI'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 almost 8 yearsTry 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. -
DannyBoi almost 8 yearsSo I did
get-member
and Localpath , Roaming Path , Status are all there. I ran the command piecewise from cmd.powershell
thengwmi
thenwin32_userprofile' it displays all the info including
Localpath , Roaming Path , Status` . Roaming path is blank however status is fine. -
DannyBoi almost 8 years@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