I have a csv file which contains a list of user names with no header. I want to end up with a second csv file which contains ONLY those user names that correspond to Active Directory users who are disabled.
I was playing around with a Get-Content and then ForEach-Object (%) loop to query the AD and return each SAM and the status of it's enabled property.
Get-Content users.csv | % {Get-ADUser $_ | Select-Object samaccountname,enabled}
Although what I really need to do is look at each name and move ONLY the ones tied to disabled accounts to a new csv file. Only I cant quite sort out how to accomplish this.