I want to run a script with a large number of user names to see if enabled using something like: 'Get-Content C:\users.txt | Get-ADUser | select SamAccountName,Enabled | Out-File C:\AcctStatus.csv' BUT I also want it to report on the ones that are no longer in AD rather than just getting the errors of cannot find an object with identity, how can I get them added in to the text file with some kind of output e.g. 'field not found' please?
This is what Search-ADAccount does. See the examples in the docs. https://docs.microsoft.com/en-us/powershell/module/addsadministration/search-adaccount?view=win10-ps, read in your file and use try/catch to perform matches.