# Free to download http://www.quest.com/powershell/activeroles-server.aspx 
# 
# List all users in that have not logged on within 
# XXX days in "Active Directory" 
#  
# Get the Current Date 
#  
$CURRENTDATE=GET-DATE 
# 
# Number of Days to check back.   
#  
$NumberDays=90 
# 
# Organizational Unit to search 
# 
$OU='ud1.utility/Accounts' 
# 
GET-QADUSER -SearchRoot $OU | where { $_.LastLogon.AddDays($NumberDays) -lt $CURRENTDATE } 
# 
# Add in a | DISABLE-QADUSER to AUTOMATICALLY Disable those accounts. 
# Line should read like this if you want to do that 
# 
# GET-QADUSER -SearchRoot $OU | where { $_.LastLogon.AddDays($NumberDays) -lt $CURRENTDATE } | DISABLE-QADUSER 