Find User Profiles on Domain Computers

Posted On 2017-12-17 by dwirch
Tags: Powershell Scripting Windows
Views: 120

This script does nothing more than search a list of computers for a specified user profile.
The script pulls a list of computer objects from Active Directory, and searches the c:\users directory on each computer for a directory name that matches the specified user name. If a matching directory name is found, then the UNC path (which includes the remote computer name) is written to the screen.
$ComputerList=Get-ADComputer -filter $ADFilter -SearchBase "$ADSearchBase" -SearchScope Subtree
ForEach($Computer in $ComputerList){
 $PathToTest="\\" + $Computer.Name + "\c$\users\$UserToSearchFor*"
 write-progress -activity "Checking remote hosts for $UserToSearchFor" -status $Computer.Name -percentcomplete (($CurrentHostNumber/$NumberOfComputers)*100)
 if((Test-path -path $PathToTest) -eq $True)
  write-host $PathToTest
write-host "`nSearch Complete.`n"


Requires the Active Directory PowerShell module be loaded in the current session.

About the Author

dwirch has posted a total of 190 articles.

Comments On This Post

No comments on this post yet!

Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.

Or you can drop a note to the administrators if you're not sure where you should post.

Your IP address is:

Before you can post, you need to prove you are human. If you log in, this test goes away.

Code Links