Get Account Expiry Date for the list of users - Powershell

**Get Account Expiry Date for the list of users - Powershell 
**

#import AD module

Import-Module ActiveDirectory;

#save the list of users in text file at any given location, mention that path below

$userlist = Get-Content "C:\folder\listofuser.txt";

# $output variable will save the result in it

$Output = foreach($user in $userlist)

{

#Querying each user and returning their respective details by using Select

Get-ADUser -property * -ldapfilter "(samaccountname=$user)"| select sAMAccountName, Displayname,accountExpirationDate, Enabled, 

Title  

};

#Mention the filename and path below to save the output

$Output| Export-csv -path "c:\folder\result.csv"

For more details click here