Get a list of old computers using Powershell

Hi guys, just a short posting here.

If you want to get a list of computer that haven’t logged in to the domain in the past X days use the following to commands:

 

$Date = [DateTime]::Today.AddDays(-X)

Get-ADComputer -Filter ‘LastLogonDate -le $Date’ -Properties LastLogonDate | FT Name,LastLogonDate

 

Just change the X to the number of days you want to display.

For instance, to display all computers that haven’t logged in in the past 90 days:

 

$Date = [DateTime]::Today.AddDays(-90)

Get-ADComputer -Filter ‘LastLogonDate -le $Date’ -Properties LastLogonDate | FT Name,LastLogonDate

 

You can also use this command to display all computers that haven’t changed their password in the past X days, for this just change the last command:

 

Get-ADComputer -Filter ‘PasswordLastSet -le $Date’ -Properties PasswordLastSet | FT Name,PasswordLastSet

Incoming search terms:

  • get list computers obsolete on powershell
  • get list of oldcomputers powershell
  • lastlogondate property get-adcomputer
  • powershell command obsolete computers
  • powershell find AD computers that haven\t logged in
  • powershell get a list of active directory computers that haven\t logged in
  • powershell get computers that haven\t logged in
  • powershell get-adcomputer lastlogontimestamp

What do you think about this post?