I am trying to come up with a solution to list the users in the local admin group on a list of servers. and select only user with names like UN12345. then check active directory to see if the account still exists. if not remove the account and profile from the server. I can dump the users into a text file but when I try and do the attached. it just parses through all accounts in AD. not the ones in my file.
Powershell
Get-Content-PathC:\Temp\test\myserver.admins.txt|ForEach-Object{Get-ADUser-LDAPFilter"(samaccountname=$_)"|Select-Object-Propertysamaccountname,enabled-ErrorActionStop}