Basic Powershell Scripting


I'm trying to find the last logon date for a list of computers in a text file. Simple question for a simple script - why is it not pulling from the Get-Content, but rather pulling all computers? Thanks in advance.

$computers = Get-Content E:\Source\StaleInputList.txt

$date_with_offset= (Get-Date).AddDays(-120)

ForEach ($computer in $computers) {

Get-ADComputer -Filter {LastLogonDate -lt $date_with_offset } -Properties * | Sort LastLogonDate | FT Name, LastLogonDate -Autosize

Parents Reply Children
No Data