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.

Example

The following example is a sample script for finding inactive or unused computers in the Fabrikam.com 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 (https://go.microsoft.com/fwlink/?LinkID=119588).

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.