Use the PowerShell command to query Active Directory for a long time without logging on to the computer account. This article takes 60 days as an example, you can modify as needed.
The following script is given:
# this PowerShell Command would query Active Directory and return the computer accounts which has not logged for the past
# days. can easily change the number of days from the number of your choosing. Lastlogondate is a Human
# Readable conversion of the lastLogonTimestamp (as far as I am able to discern. More details about the timestamp can
$then = (get-date). AddDays ( -60) # The number of days from today since to the last logon.
Get-adcomputer-property name,lastlogondate-filter {lastlogondate-lt $then} | FT name,lastlogondate
# If you would like to Disable these computer accounts, uncomment the following line:
# get-adcomputer-property Name,lastlogondate-filter {lastlogondate-lt $then} | Set-adcomputer-enabled $false
# If you would as to Remove these computer accounts, uncomment the following line:
# get-adcomputer-property Name,lastlogondate-filter {lastlogondate-lt $then} | Remove-adcomputer
PowerShell queries for long-running computer objects that are not logged in the AD domain