How to use powershell to check the location of user profile locations on the server?
Solution 1
In powershell, use the Win32_UserProfile WMI Object to find profiles remotely:
gwmi -ComputerName <computername> Win32_UserProfile
To find user profiles not on a server (or that are, either way), you could do something like:
gwmi -ComputerName <computername> Win32_UserProfile | ? {"C:\Users\<username>" -contains $_.LocalPath}
If the path exists, it will give results if not then it won't. You can do fancier stuff than this, but basically this should accomplish what you need without using regular expressions.
Solution 2
For current user run:
$env:USERPROFILE
To get list of all environmental variables, run:
Get-ChildItem Env:
Related videos on Youtube
leeand00
Projects jobdb - Creator of Open Source Job Search Document Creator/Tracker http://i9.photobucket.com/albums/a58/Maskkkk/c64nMe.jpg Received my first computer (see above) at the age of 3, wrote my first program at the age of 7. Been hooked on programming ever since.
Updated on September 18, 2022Comments
-
leeand00 over 1 year
Is it possible to find all the users profiles that are not on a certain server/folder using powershell and regular expressions? If so how would one go about this?