Company LANID or USERID all in a text file with one id on each line to retrieve the users Full Name
script assumes c:\scripts path has a file named usersnames.txt. you can replace this with your own path
$User = $env:USERNAME
$source = Get-Content c:\scripts\usernames.txt
foreach ($User in $source)
{
$Search = New-Object DirectoryServices.DirectorySearcher([ADSI]“”)
$Search.filter = “(&(objectClass=user)(sAMAccountName=$User))”
$results = $Search.Findall()
Foreach($result in $results){
$User = $result.GetDirectoryEntry()
$realname = $user.DistinguishedName
the output of the file can be found in c:\temp\realname.txt
$realname | out-file -append c:\temp\realname.txt
}
}