PowerShell Script to find LastLogonDate and PasswordLastSet information from Active Directory for list of computers in a text file

1
2
3
4
[Array]$OutList = foreach ($computer in Get-Content -Path C:\Temp\InputFile.txt) {
Get-ADComputer -Identity $computer -Property LastLogonDate, PasswordLastSet -ErrorAction SilentlyContinue | select Name, LastLogonDate, PasswordLastSet
}
$OutList | Export-CSV C:\Temp\OutputFile.csv -NoTypeInformation

Leave a Reply

Your email address will not be published.