One liner. This loops through all account names in a text file and then exports all of the results to a csv file. If you try to add the export-csv portion inside of the foreach loop, the csv file will constantly get overwritten after every account is queried. In other words, export-csv doesn’t automatically append.
$users = gc userlist.txt | foreach { qaduser $_ | select logonname, accountexpires} | export-csv userinfo.csv
Tip: You can add additional fields such as firstname, lastname, initials, passwordstatus, lastlogon, creationdate, passwordlastset, accountisdisabled, passwordexpires, and others. For a list of what is available you can enter this from the Quest Management Shell:
qaduser username | select *
Replace username with a valid username. This results in the output below. The fields you can add are located on the left. Information censored for obvious reasons.
