How to Find Inactive Computers in Active Directory using PowerShell.
To identify inactive computer accounts, you will always target those that have not logged on to Active Directory in the last 90 dagen. To accomplish this goal, you need to target theLastLogonTimeStamp property and then specify a condition with the time as shown in the following PowerShell commands:
$DaysInactive = 90
$time = (Get-Date).Adddays(-($DaysInactive))
Get-ADComputer -Filter {LastLogonTimeStamp -lt $time} -ResultPageSize 2000 -resultSetSize $null -Properties Name, OperatingSystem, SamAccountName, DistinguishedName
If you wish to search computer accounts that have been inactive for more than 90 dagen, all you need to do is modify the$DaysInActive variable value. The current value is set at 90 dagen; however, you can specify your own value.
To export output to a CSV file, add theExport-CSV PowerShell cmdlet as shown in the following command:
Get-ADComputer -Filter {LastLogonTimeStamp -lt $time} -ResultPageSize 2000 -resultSetSize $null -Properties Name, OperatingSystem, SamAccountName, DistinguishedName | Export-CSV "C:\Temp\StaleComps.CSV" –NoTypeInformation
¿Porqué me devuelve en algunas cuentas Enabled: True?
Hoi. Can you add any screenshots for this?