Quantcast
Channel: Directory Services forum
Viewing all articles
Browse latest Browse all 31638

Powershell Command to Disable user account older then 90 days

$
0
0

Hello Guys,

Just wanted to know is it possible to disabled the user account older then 90 days but skip those users who's passwordnever expired is set. 

DONT_EXPIRE_PASSWORD0x1000065536

I am using below script

Get-ADUser -Filter * -SearchBase "OU=Users,DC=Testlab,DC=com" -Properties whenCreated,whenChanged | Where-Object {$_.whenCreated -le ((Get-Date).AddDays(-90)).Date} | Where-Object {$_.whenChanged -le ((Get-Date).AddDays(-90)).Date} | Disable-ADAccount


Viewing all articles
Browse latest Browse all 31638

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>