Instructions
Run the following PowerShell code in a PowerShell window to create a csv formated list of inactive computer workstations. The list will be named Inactiveworkstations.cvs and will be found in the temp folder of drive c:. Your account must have the necessary rights to get the list from Active Directory Services.
Code:
Import-Module activedirectory [int]$ComputerPasswordAgeDays = 90 IF ((test-path "c:\temp") -eq $False) { md "c:\temp" } $ExportFile = "c:\temp\InactiveWorkstations.csv" $ComputerStaleDate = (Get-Date).AddDays(-$ComputerPasswordAgeDays) $InactiveWorkstations = Get-ADComputer -filter { (passwordLastSet -le $ComputerStaleDate) -and (OperatingSystem -notlike "*Server*") -and (OperatingSystem -like "*Windows*") } -properties Name, DistinguishedName, OperatingSystem,OperatingSystemServicePack, passwordLastSet,LastLogonDate,Description $InactiveWorkstations | export-csv $ExportFile