Sometimes it may be desirable to search the Active Directory for certain criteria and to make a list of the applicable users. We also faced the problem that we want to filter out users who still had a server-stored profile from the Active Directory.
This became necessary because we want to say goodbye to this type of profile storage due to the numerous problems with server-stored profiles and the different profile versions (roaming profiles) . For users who often change workplaces, it makes sense to continue using server-saved profiles , but we wanted to get an overview of the users with the evaluation who have currently entered a profile path in AD .
To do this, you have to call up a PowerShell console as administrator. The fastest way to do this is as we described it in our article ” Quickly open Command Prompt (CMD) and PowerShell as an administrator using a key combination “.
Then you must first import the “Active Directory” module so that you can also access the functions of the Active Directory. The command is:
ActiveDirectory import modules
The command to output the list of user accounts with a registered profile path is as follows:
Get-ADUser -Filter {(ProfilePath -like “*”)} -Properties SamAccountName | select SamAccountName
This command sets a filter on the profile path (ProfilePath) and filters only those user accounts whose profile path contains an entry. The output in the PowerShell console then looks like this.
If the user list in the PowerShell is too long, you can of course also redirect the output to a text file. Simply add the command ” > C: Temp User.txt ” to the above command , and the output will be redirected to the file. The file name and the path can of course be adjusted.
In the past we have reported many other useful PowerShell commands :
– Query free and used hard disk space locally or remotely using PowerShell
– Change Windows date and time using PowerShell – Display
file rights using PowerShell
– Read WindowsUpdate.log on Windows 10 or reformat using PowerShell – Install
Windows roles and features using PowerShell
– Read out computer system information with PowerShell
–
Query Exchange quotas (Quota) settings with PowerShell – Prepare the Windows client for remote PowerShell commands with WINRM – Edit
local users and groups with
PowerShell
– Determine Windows system runtime with PowerShell – Windows 10 system restore point with Create
PowerShell
– shutdown and restart Windows with PowerShell commands – repair Windows component store with DISM and PowerShell commands
– switch off UAC (user account control ) via PowerShell or registry in Windows 10
– PowerShell command to deactivate de r firewall