The Microsoft PowerShell script below may be used to query a list of Microsoft Active Directory SAMAccountNames from a Notepad (.txt) file and output the Given Name and Enabled status in a CSV file.

 

#This scrip will query a list of SAMAccountNames from a notepad (.txt) file and provide the Name and Enabled status
#
#Provide the path to the Notepad (.txt) file tha contains the list of SAMAccountNames
$– USERS = Get-Content “<<File Path>>”
$– USERS | ForEach {Get-ADUser $_ -Properties * | Select SAMAccountName, Name, Enabled} | Export-CSV -Path “<<File Path>>”

 

Enjoy!