Solved

Turn off Password never expires on local administrator account

Posted on 2014-10-26
3
2,529 Views
Last Modified: 2014-11-03
Hello Experts,

we have some servers where the Password Never Expires flag is checked , and I am trying to find out a scripting way to uncheck these option so that password expires on the Local administrator account.

EE
There are -bor 0x10000 (https://social.technet.microsoft.com/Forums/en-US/e4e96a5e-3b28-4673-8c61-d4abdf8f2426/win-7-setting-the-option-password-never-expires-for-a-specific-local-user?forum=winserverpowershell) which turn this option ON.

But , what is need is exact opposite. I want to turn off the option so that , the password gets expired.

Thanks,

-Prashant Girennavar.
0
Comment
Question by:Prashant Girennavar
3 Comments
 
LVL 3

Expert Comment

by:Sandeep Khanagwal
ID: 40405847
Below Solution provided by one of our EE member Mike Kline. It will help you .

You can also use adfind and admod from Joe richards

http://www.joeware.net/freetools/tools/adfind/index.htm

http://www.joeware.net/freetools/tools/admod/

adfind -default -bit -f "&(objectcategory=person)(objectclass=user)(useraccountcontrol:AND:=65536)" useraccountcontrol -adcsv | admod -sc uacclear:dont_expire_password -unsafe

I've included two screenshots

The first is just the adfind command not piped to admod to show you what accounts have the flag set for the password to never expire.

Note by default admod only changes 10 objects (great safety feature).  I added the -unsafe switch and it will do all the accounts.

Thanks
password-not-expire-adfind.jpg
password-not-expire-admod.jpg
0
 
LVL 10

Author Comment

by:Prashant Girennavar
ID: 40405855
Hello Sandeep,

This is not about AD account. This is about local administrator account on member servers.

Any other suggestions please.

Thanks,

-Prashant Girennavar.
0
 
LVL 16

Accepted Solution

by:
Joshua Grantom earned 500 total points
ID: 40406305
This should do it. Just create a txt file with the server names you want to disable for.

$servers = Get-Content C:\ServerList.txt | % {Invoke-Command -Session $_ -ScriptBlock {wmic path Win32_UserAccount where Name='Administrator' set PasswordExpires=true}}

Open in new window


or you can do it for all windows servers

$servers = Get-ADComputer -Filter {OperatingSystem -like "Windows Server*"} | % {Invoke-Command -Session $_ -ScriptBlock {wmic path Win32_UserAccount where Name='Administrator' set PasswordExpires=true}}

Open in new window

0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show, step by step, how to integrate R code into a R Sweave document
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now