Summary: Use Windows PowerShell to work with Active Directory date fields.
How can I Use Windows PowerShell to work with date fields in Active Directory?
Try the following techniques:
# Password last set within the last 30 days?
$pwdLastSet = Get-ADUser Administrator -Properties pwdLastSet |
Select-Object -ExpandProperty pwdLastSet
# Option A
$pwdLastSet -gt (Get-Date).AddDays(-30).ToFileTimeUTC()
# Option B
[datetime]::fromFileTimeUTC($pwdLastSet) -gt (Get-Date).AddDays(-30)
0 comments