Tag: Active Directory

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

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

Find SMTP-adress in Active Directory

1. Run Active Directory Users and Computers.

2. Right-click the domain object and choose Find from the context menu. This will bring up the Find Users,

Contacts, and Groups window.

3. In the Find drop-down list, choose Custom Search.

4. Click the Advanced tab and in the Enter LDAP query: field, enter the following text: proxyaddresses=smtp:emailaddress@”yourdomain.com”

5. Click the Find Now button.