posted Sep 15, 2011 3:35 PM by Eric Dombroski
[
updated Sep 15, 2011 3:41 PM
]
# Return AD users who have not set their password since a date supplied via argument
If(!$Args[0]) {Write-Error "No Date Given"; Exit}
#Clear Errors, Get Date, Exit on Invalid Date
$Error.Clear()
$Date = [datetime]$Args[0]
If($Error){Write-Error "Invalid Date"; Exit}
#Import AD cmdlets
Import-Module ActiveDirectory
#Get AD Users
Write-Host "Getting AD Users... Please Wait..."
$Users = Get-ADUser -Searchbase "OU=People,DC=Domain,DC=Com" -filter * -properties passwordlastset
#Go through Users
Foreach($User in $Users) {
If($user.passwordlastset -lt $date) {
$user
}
} |
|