tabush
asked on
Powershell Script to change AD attribute pwlastset - (ET)
Can someone help me write a powershell that does the following?
I want to change pwdlastset active directory attribute on a specified OU
If password age is greater than 175 days then:
- Change pwdlastset to 0 and commit that to AD
- Change pwdlastset to -1 and commit that to AD
*skip if user account is set to pw never expire.
I'm putting a new 180 day password policy in place and i dont want it to force an immediate password expiration on people who's password is older than 180 days. I'm using a tool that will notify them in the last 10 days of expiration but if it expires right away this tool wont help.
I want to change pwdlastset active directory attribute on a specified OU
If password age is greater than 175 days then:
- Change pwdlastset to 0 and commit that to AD
- Change pwdlastset to -1 and commit that to AD
*skip if user account is set to pw never expire.
I'm putting a new 180 day password policy in place and i dont want it to force an immediate password expiration on people who's password is older than 180 days. I'm using a tool that will notify them in the last 10 days of expiration but if it expires right away this tool wont help.
ASKER
Setting to 0 sets it to never but also enables the "force pw change at next login"
Only option i found around that is setting to 0 then to -1 which set's the pwlastset to todays date.
Only option i found around that is setting to 0 then to -1 which set's the pwlastset to todays date.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Again, and like the "What if:" in the output suggests: it's in test mode; you'll need to remove the two "-WhatIf"s in lines 6 and 7 to run it for real.
ASKER
Sorry my mistake. I didnt read it carefully.
ASKER
Thanks this is exactly what i was looking for.
This is in test mode and will only display the users it would change; remove the -WhatIf in line 6 to run it for real:
Open in new window