Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

AD PowerShell: Difference between Search-ADAccount and Get-ADComputer

$
0
0

I have been working with some scripts to search for and delete stale AD Computers in our domain that have not logged in or been inactive for 180 days. I have tried both Search-ADAccount and Get-ADComputer for the initial search and I have noticed an interesting discrepancy. For some reason when searching with

Get-ADAccount -AccountInactive -TimeSpan 180.00:00:00

the report does not seem to go back exactly 180 days. It is closer to 196. Using

Get-ADComputer -Filter {lastLogonTimestamp -lt $lastLogon}

(with $lastLogon = (Get-Date).adddays(-180).ToFileTime()) it does seem to return the exact range.

Does anyone know what might account for this?



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>