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.
Param(
[Parameter(Mandatory=$True,Position=1)]
[String]$UserToSearchFor
)
$ADFilter="*"
$ADSearchBase="OU=computers,DC=mydomain,DC=com"
$ComputerList=Get-ADComputer -filter $ADFilter -SearchBase "$ADSearchBase" -SearchScope Subtree
$NumberOfComputers=$ComputerList.Count
$CurrentHostNumber=1
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
}
$CurrentHostNumber++
}
write-host "`nSearch Complete.`n"