Jump to content

Prevent password expiration


Recommended Posts

Hello,

would someone be able to tell me if it is possible to use the Autounattend file to set Windows to NOT expire a password for an account which is created in the autounattend file please?

I did use the search function but could not find anything relevant.

Thank you.

Link to comment
Share on other sites


Here is a little powershell snippet I am using....

$EXPIRY = gwmi win32_USERACCOUNT | Where-Object {$_.NAME -eq "MrJinje"};$EXPIRY.PasswordExpires = $False;$EXPIRY.Put()

But I guess you want to use your autounattend.xml, so instead you should probably run this command during first login.

wmic useraccount where "name='MrJinje'" set PasswordExpires=FALSE

Both scripts do the same thing, doesn't matter which you use.

Link to comment
Share on other sites

Here is a little powershell snippet I am using....

$EXPIRY = gwmi win32_USERACCOUNT | Where-Object {$_.NAME -eq "MrJinje"};$EXPIRY.PasswordExpires = $False;$EXPIRY.Put()

But I guess you want to use your autounattend.xml, so instead you should probably run this command during first login.

wmic useraccount where "name='MrJinje'" set PasswordExpires=FALSE

Both scripts do the same thing, doesn't matter which you use.

Thanks very much for replying MrJinje...I found the wmic command on Experts Exchange soon after I posted my question. I made a batch file which I ran from SetupComplete.cmd and tested on a virtual machine and it works like a charm.

Thanks again :)

Link to comment
Share on other sites

then make it simpler from setupcomplete.cmd no scripts

cmd /C start /wait NET ACCOUNTS /MAXPWAGE:UNLIMITED

C:\Users\YOURNAME>NET ACCOUNTS
Force user logoff how long after time expires?: Never
Minimum password age (days): 0
Maximum password age (days): Unlimited

Link to comment
Share on other sites

hi

if i used "wmic useraccount where "name='MrJinje'" set PasswordExpires=FALSE"

where would i put it in my autonated xml

cheers

and if ive already installed

and want to stop the password expiring

how would i do that

cheers

Link to comment
Share on other sites

If you pop over to Max's thread (see sticky) you will find some good examples.

Place it in the oobesystem pass during the Microsoft-Windows-Shell-Setup component

            <FirstLogonCommands>
<SynchronousCommand wcm:action="add">
<Order>1</Order>
<Description>making the magic happen</Description>
<CommandLine>cmd /C wmic useraccount where "name='Bob'" set PasswordExpires=FALSE</CommandLine>
</SynchronousCommand>
</FirstLogonCommands>

Edited by MrJinje
Link to comment
Share on other sites

If you pop over to Max's thread (see sticky) you will find some good examples.

Place it in the oobesystem pass during the Microsoft-Windows-Shell-Setup component

            <FirstLogonCommands>
<SynchronousCommand wcm:action="add">
<Order>1</Order>
<Description>making the magic happen</Description>
<CommandLine>cmd /C wmic useraccount where "name='Bob'" set PasswordExpires=FALSE</CommandLine>
</SynchronousCommand>
</FirstLogonCommands>

and probably best to use that to only get user intended from Firstlogon, my example above may get all users but not sure

Link to comment
Share on other sites

  • 1 year later...

Hey all, need some help.

I am trying to create a user but also have the "password never expires" box checked after a unattended install.

It will work if i manually run the cmd file after install with the checkbox but if i run unattended with following setup it doesnt add the checkbox

Any ideas would be helpful

Also i was sure if to put this in the unattended area but saw password expiration title

current folder structure:

$OEM$/

files inside = cmdlines.txt and useraccounts.cmd

cmdlines.txt:

[COMMANDS]

"useraccounts.cmd"

useraccounts.cmd:

net user Admin /add /PASSWORDCHG:YES /expires:never /passwordreq:no

net localgroup Administrators Admin /add

net localgroup Users Admin /delete

WMIC USERACCOUNT WHERE "Name='Admin'" SET PasswordExpires=FALSE

EXIT

Thanks for any help or ideas

Bill

Link to comment
Share on other sites

Thanks but it didnt work...

I want admin delete to remove him from users group and only be in adminstrators group

I am probably doing this the wrong way but i need it to run as part of a unattended install.

everything works except the checkbox not being added.

thanks for the help

Bill

Link to comment
Share on other sites

I don't know where to find "password never expires" box but

If I go to Admin prompt and type Net User memememe

Account active Yes

Account expires Never

Password last set 7/17/2011 5:05:52 AM

Password expires Never

Edited by maxXPsoft
Link to comment
Share on other sites

thanks guys but got it working....

So now when I do a fresh unattended install, at the end of the install it will add a user, make changes and auto logon that user...

I thinks it ugly but it works

folder structure:

$oem$

---CMDLINES.TXT

---useraccounts.CMD

---autologon.reg

------\$1

---------\Install

------------START.CMD

  cmdlines.txt

[COMMANDS]
"useraccounts.cmd"

    useraccounts.CMD

net user Admin /add /PASSWORDCHG:YES
net localgroup Administrators Admin /add
net localgroup Users Admin /delete
REGEDIT /S autologon.reg
EXIT

   autologon.reg

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"DefaultUserName"="Admin"
"DefaultPassword"=""
"AutoAdminLogon"="1"

    start.cmd

CLS
@echo off

ECHO.
ECHO adding password never expires checkbox
WMIC USERACCOUNT WHERE "Name='Admin'" SET PasswordExpires=FALSE

ECHO.
ECHO Deleting Temp Installation Files...
RD /S /Q %systemdrive%\install

EXIT

Link to comment
Share on other sites

I had to boot into Ultimate cause don't have box on Premium. gonna anytime update here in a few days

I was able to do that with an Administrator command prompt. Then checked box and it was checked

C:\Windows\system32>wmic useraccount where "name='xxxxx'" set PasswordExpires=FALSE
Updating property(s) of '\\xxxxxxxx\ROOT\CIMV2:Win32_UserAccount.Domain="xxxxxx",Name="xxxxxx"'
Property(s) update successful.

Edited by maxXPsoft
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...