Quantcast
Channel: Hey, Scripting Guy! Blog
Viewing all articles
Browse latest Browse all 3333

PowerTip: Use PowerShell to Work with Active Directory Date Fields

$
0
0

Summary: Use Windows PowerShell to work with Active Directory date fields.

Hey, Scripting Guy! Question How can I Use Windows PowerShell to work with date fields in Active Directory?

Hey, Scripting Guy! Answer 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)

 


Viewing all articles
Browse latest Browse all 3333

Trending Articles