Force all AD user accounts change their passwords at next logon

Hello Experts,
I am looking for a command to force all users in a particular OU  to immediate change their current password settings from "Password Never Expires" to "User Must change password at next logon" so that this will force every users in that particular OU to immediately to change their current password. The "OU=Marketing,DC=contoso,DC=com"

I am using windows 2008 32-Bit SP1 domain Controller.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott GorcesterCTOCommented:
dsquery user | dsmod user -mustchpwd yes
This command force all the users must change their passwords on next logon, CAUTION its include Domain Administrator also.

You can also use "ou" for a group of users instead of "user"
smpvmAuthor Commented:
Hello Moosesupport,

How can we customize this command for a particular OU only say "OU=Marketing,DC=contoso,DC=com" and i don't want to make any disaster for any other users residing in other OU's

Scott GorcesterCTOCommented:
dsquery user ou=users,dc=domain,dc=local | dsmod user -mustchpwd yes

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

Scott GorcesterCTOCommented:
make sure the proper values are added for your OU and domain.
smpvmAuthor Commented:
Thank you moosesupport it is working.
Seth SimmonsSr. Systems AdministratorCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Legacy OS

From novice to tech pro — start learning today.