Finding Inactive or Unused Computers

Applies To: Windows Server 2008 R2

This topic explains how to use the Active Directory module for Windows PowerShell to find inactive or unused computers.


The following example is a sample script for finding inactive or unused computers in the domain:

$lastSetdate = [DateTime]::Now - [TimeSpan]::Parse("45")
Get-ADComputer -Filter {PasswordLastSet -le $lastSetdate} -Properties passwordLastSet -ResultSetSize $null | FT samaccountname,PasswordLastSet

A script is a series of Active Directory PowerShell cmdlets. For more information about running Active Directory PowerShell scripts, see Running Windows PowerShell Scripts (

Additional information

For a full explanation of the parameters that you can pass to Get-ADComputer, at the Active Directory module command prompt, type Get-Help Get-ADComputer –detailed, and then press ENTER.