This article has not been completed yet. However, it may already contain helpful Information and therefore it has been published at this stage.
# PowerShell Command to be run on a DC
# It displays all computer objects that are inactive and where no login activity has taken place in the last 31 days.
Search-ADAccount -ComputersOnly -AccountInactive -TimeSpan "31" | Where-Object { $_.Enabled -eq $true } | Select Name
# tested on a Windows Server 2019
References:
Powershell script to find old AD computers by last login time (spiceworks.com)