Home > Microsoft > AD: Get lists of users and computers that is not in use

AD: Get lists of users and computers that is not in use

January 18, 2013

Here i have listed some powershell commands to get lists of users that have never logged in to your domain and one line to get a list of computers that never has logged in within an time span of 365 days.

I run these powershell commands in Windows PowerShell ISE that is a nice little program thats included in Windows Server (add feature), when you use PowerShell ISE you need to import Active Directory cmdlets by running “Import-Module ActiveDirectory”

# Import the ActiveDirectory cmdlets
Import-Module ActiveDirectory

#List Active Directory users that have never logged
#in including built-in users using PowerShell
get-aduser -f {-not ( lastlogontimestamp -like “*”) -and (enabled -eq $true)} | select name

#List Active Directory Computers that have never logged
#in within time span (-TimeSpan 365.00:00:00, this is 365 days)
Search-ADAccount -AccountInactive -ComputersOnly -TimeSpan 35.00:00:00 | select name | sort-object name

%d bloggers like this: