Results 1 to 6 of 6

Thread: net user password never expires option

  1. #1
    network admin in need of help Guest

    net user password never expires option

    i am using net user batch file to create and add 142 user, i need to use the
    password never expires option, but i am running into an issue, here is what i
    have

    net user ons1 #!wdfons1 /add /expires:never /passwordchg:no

    the result of this is the line saying the comand completed successfully,
    however when i look at the user properties, i see that the user cannot change
    password selection is marked, but the password nerver expires box is not
    marked.

    i am running this on windows 2000 server

    what have i done wrong. any help would be greatly appreciated.


  2. #2
    Michael Harris \(MVP\) Guest

    Re: net user password never expires option

    network admin in need of help wrote:
    > i am using net user batch file to create and add 142 user, i need to
    > use the password never expires option, but i am running into an
    > issue, here is what i have
    >
    > net user ons1 #!wdfons1 /add /expires:never /passwordchg:no
    >
    > the result of this is the line saying the comand completed
    > successfully, however when i look at the user properties, i see that
    > the user cannot change password selection is marked, but the password
    > nerver expires box is not marked.
    >
    > i am running this on windows 2000 server
    >
    > what have i done wrong. any help would be greatly appreciated.



    Per C:\>net user /help

    /expires:never would apply to the user account expiration, not the password.

    Try this Jerold Schulman solution...

    JSI Tip 9625. How can a batch set a user's UserAccountControl attribute for
    'Password never expires' on or off?
    <http://www.jsifaq.com/SF/Tips/Tip.aspx?id=9625>

    --
    Michael Harris
    Microsoft MVP Scripting



  3. #3
    brian metzger Guest

    Re: net user password never expires option



    "Michael Harris (MVP)" wrote:

    > network admin in need of help wrote:
    > > i am using net user batch file to create and add 142 user, i need to
    > > use the password never expires option, but i am running into an
    > > issue, here is what i have
    > >
    > > net user ons1 #!wdfons1 /add /expires:never /passwordchg:no
    > >
    > > the result of this is the line saying the comand completed
    > > successfully, however when i look at the user properties, i see that
    > > the user cannot change password selection is marked, but the password
    > > nerver expires box is not marked.
    > >
    > > i am running this on windows 2000 server
    > >
    > > what have i done wrong. any help would be greatly appreciated.

    >
    >
    > Per C:\>net user /help
    >
    > /expires:never would apply to the user account expiration, not the password.
    >
    > Try this Jerold Schulman solution...
    >
    > JSI Tip 9625. How can a batch set a user's UserAccountControl attribute for
    > 'Password never expires' on or off?
    > <http://www.jsifaq.com/SF/Tips/Tip.aspx?id=9625>
    >
    > --
    > Michael Harris
    > Microsoft MVP Scripting
    >
    >
    > thank you for your assistance.


    this does not look like it is working for me. it may just be me, i am new to
    scripting, i have written 3 .vbs and about 5 .bat and i am still an infant at
    it, learning more and more each day. can you explain to me what i would need
    to do to set it to work for me, or is there a line or 2 out of it that i need
    to incorporate into the script that i have?

    thanks again
    brian metzger

  4. #4
    Jerold Schulman Guest

    Re: Re: net user password never expires option

    On Sat, 23 Sep 2006 06:07:01 -0700, brian metzger <brianmetzger@discussions.microsoft.com> wrote:

    >
    >
    >"Michael Harris (MVP)" wrote:
    >
    >> network admin in need of help wrote:
    >> > i am using net user batch file to create and add 142 user, i need to
    >> > use the password never expires option, but i am running into an
    >> > issue, here is what i have
    >> >
    >> > net user ons1 #!wdfons1 /add /expires:never /passwordchg:no
    >> >
    >> > the result of this is the line saying the comand completed
    >> > successfully, however when i look at the user properties, i see that
    >> > the user cannot change password selection is marked, but the password
    >> > nerver expires box is not marked.
    >> >
    >> > i am running this on windows 2000 server
    >> >
    >> > what have i done wrong. any help would be greatly appreciated.

    >>
    >>
    >> Per C:\>net user /help
    >>
    >> /expires:never would apply to the user account expiration, not the password.
    >>
    >> Try this Jerold Schulman solution...
    >>
    >> JSI Tip 9625. How can a batch set a user's UserAccountControl attribute for
    >> 'Password never expires' on or off?
    >> <http://www.jsifaq.com/SF/Tips/Tip.aspx?id=9625>
    >>
    >> --
    >> Michael Harris
    >> Microsoft MVP Scripting
    >>
    >>
    >> thank you for your assistance.

    >
    >this does not look like it is working for me. it may just be me, i am new to
    >scripting, i have written 3 .vbs and about 5 .bat and i am still an infant at
    >it, learning more and more each day. can you explain to me what i would need
    >to do to set it to work for me, or is there a line or 2 out of it that i need
    >to incorporate into the script that i have?
    >
    >thanks again
    >brian metzger


    Where is it failing?
    Did you change the @echo off to @echo on, remove the >nul 2>&1
    and log the output?


    Jerold Schulman
    Windows Server MVP
    JSI, Inc.
    http://www.jsiinc.com
    http://www.jsifaq.com

  5. #5
    brian metzger Guest

    Re: Re: net user password never expires option



    "Jerold Schulman" wrote:

    > On Sat, 23 Sep 2006 06:07:01 -0700, brian metzger <brianmetzger@discussions.microsoft.com> wrote:
    >
    > >
    > >
    > >"Michael Harris (MVP)" wrote:
    > >
    > >> network admin in need of help wrote:
    > >> > i am using net user batch file to create and add 142 user, i need to
    > >> > use the password never expires option, but i am running into an
    > >> > issue, here is what i have
    > >> >
    > >> > net user ons1 #!wdfons1 /add /expires:never /passwordchg:no
    > >> >
    > >> > the result of this is the line saying the comand completed
    > >> > successfully, however when i look at the user properties, i see that
    > >> > the user cannot change password selection is marked, but the password
    > >> > nerver expires box is not marked.
    > >> >
    > >> > i am running this on windows 2000 server
    > >> >
    > >> > what have i done wrong. any help would be greatly appreciated.
    > >>
    > >>
    > >> Per C:\>net user /help
    > >>
    > >> /expires:never would apply to the user account expiration, not the password.
    > >>
    > >> Try this Jerold Schulman solution...
    > >>
    > >> JSI Tip 9625. How can a batch set a user's UserAccountControl attribute for
    > >> 'Password never expires' on or off?
    > >> <http://www.jsifaq.com/SF/Tips/Tip.aspx?id=9625>
    > >>
    > >> --
    > >> Michael Harris
    > >> Microsoft MVP Scripting
    > >>
    > >>
    > >> thank you for your assistance.

    > >
    > >this does not look like it is working for me. it may just be me, i am new to
    > >scripting, i have written 3 .vbs and about 5 .bat and i am still an infant at
    > >it, learning more and more each day. can you explain to me what i would need
    > >to do to set it to work for me, or is there a line or 2 out of it that i need
    > >to incorporate into the script that i have?
    > >
    > >thanks again
    > >brian metzger

    >
    > Where is it failing?
    > Did you change the @echo off to @echo on, remove the >nul 2>&1
    > and log the output?
    >
    >
    > Jerold Schulman
    > Windows Server MVP
    > JSI, Inc.
    > http://www.jsiinc.com
    > http://www.jsifaq.com


    i did not, i have now, this is what i have

    @echo on
    setlocal
    if {%2}=={} goto err
    set ons1=%1
    set YN=%2
    set /a pnx=65536
    set /a upnx=0
    if /i "%YN%" EQU "Y" goto swok
    if /i "%YN%" NEQ "N" goto err
    :swok
    set /a userAccountControl=999999999
    call :getusr
    if %userAccountControl% EQU 999999999 goto usrnf
    if /i "%YN%" EQU "N" goto setoff
    set /a upnx=%userAccountControl% ^& %pnx%
    if %upnx% EQU %pnx% goto finish
    set /a userAccountControl=%userAccountControl% ^| 65536
    call :updusr>
    goto finish
    :setoff
    set /a upnx=%userAccountControl% ^& %pnx%
    if %upnx% NEQ %pnx% goto finish
    set /a userAccountControl=%userAccountControl% ^^ 65536
    call :updusr
    :finish
    endlocal
    goto :EOF
    :err
    @echo Syntax: PwdNX ons1 Y^|N
    endlocal
    :usrnf
    @echo Syntax: PwdNX ons1 Y^|N - %ons1% NOT found.
    endlocal
    goto :EOF
    :getusr
    for /f "Tokens=2 Delims=: " %%a in ('adfind -b %ons1% -nodn -noctl
    userAccountControl^|find /i "userAccountControl"') do (
    set /a userAccountControl=%%a
    )
    goto :EOF
    :updusr
    admod -b %ons1% "userAccountControl::%userAccountControl%"



    this is what the results are:
    the user name i am testing is ons1

    password never expires option is still not checked.

    and the cmd prompt shows the following

    i ran from cmd prompt

    c:\>pwdnvrx.bat
    (this is the result)
    c:\>setlocal

    c:\>if {} == {} goto err
    syntax PwdNX ons1 Y:N

    c:\>endlocal
    Syntax: PwdNX ons1 Y:N - NOT found.

    c:\>endlocal

    c:\>goto :EOF

    c:\>

    what have i messed up.
    thanks for your help
    brian metzger




    >


  6. #6
    Jerold Schulman Guest

    Re: Re: Re: net user password never expires option

    On Sat, 23 Sep 2006 07:17:02 -0700, brian metzger <brianmetzger@discussions.microsoft.com> wrote:

    >
    >
    >"Jerold Schulman" wrote:
    >
    >> On Sat, 23 Sep 2006 06:07:01 -0700, brian metzger <brianmetzger@discussions.microsoft.com> wrote:
    >>
    >> >
    >> >
    >> >"Michael Harris (MVP)" wrote:
    >> >
    >> >> network admin in need of help wrote:
    >> >> > i am using net user batch file to create and add 142 user, i need to
    >> >> > use the password never expires option, but i am running into an
    >> >> > issue, here is what i have
    >> >> >
    >> >> > net user ons1 #!wdfons1 /add /expires:never /passwordchg:no
    >> >> >
    >> >> > the result of this is the line saying the comand completed
    >> >> > successfully, however when i look at the user properties, i see that
    >> >> > the user cannot change password selection is marked, but the password
    >> >> > nerver expires box is not marked.
    >> >> >
    >> >> > i am running this on windows 2000 server
    >> >> >
    >> >> > what have i done wrong. any help would be greatly appreciated.
    >> >>
    >> >>
    >> >> Per C:\>net user /help
    >> >>
    >> >> /expires:never would apply to the user account expiration, not the password.
    >> >>
    >> >> Try this Jerold Schulman solution...
    >> >>
    >> >> JSI Tip 9625. How can a batch set a user's UserAccountControl attribute for
    >> >> 'Password never expires' on or off?
    >> >> <http://www.jsifaq.com/SF/Tips/Tip.aspx?id=9625>
    >> >>
    >> >> --
    >> >> Michael Harris
    >> >> Microsoft MVP Scripting
    >> >>
    >> >>
    >> >> thank you for your assistance.
    >> >
    >> >this does not look like it is working for me. it may just be me, i am new to
    >> >scripting, i have written 3 .vbs and about 5 .bat and i am still an infant at
    >> >it, learning more and more each day. can you explain to me what i would need
    >> >to do to set it to work for me, or is there a line or 2 out of it that i need
    >> >to incorporate into the script that i have?
    >> >
    >> >thanks again
    >> >brian metzger

    >>
    >> Where is it failing?
    >> Did you change the @echo off to @echo on, remove the >nul 2>&1
    >> and log the output?
    >>
    >>
    >> Jerold Schulman
    >> Windows Server MVP
    >> JSI, Inc.
    >> http://www.jsiinc.com
    >> http://www.jsifaq.com

    >
    >i did not, i have now, this is what i have
    >
    >@echo on
    >setlocal
    >if {%2}=={} goto err
    >set ons1=%1
    >set YN=%2
    >set /a pnx=65536
    >set /a upnx=0
    >if /i "%YN%" EQU "Y" goto swok
    >if /i "%YN%" NEQ "N" goto err
    >:swok
    >set /a userAccountControl=999999999
    >call :getusr
    >if %userAccountControl% EQU 999999999 goto usrnf
    >if /i "%YN%" EQU "N" goto setoff
    >set /a upnx=%userAccountControl% ^& %pnx%
    >if %upnx% EQU %pnx% goto finish
    >set /a userAccountControl=%userAccountControl% ^| 65536
    >call :updusr>
    >goto finish
    >:setoff
    >set /a upnx=%userAccountControl% ^& %pnx%
    >if %upnx% NEQ %pnx% goto finish
    >set /a userAccountControl=%userAccountControl% ^^ 65536
    >call :updusr
    >:finish
    >endlocal
    >goto :EOF
    >:err
    >@echo Syntax: PwdNX ons1 Y^|N
    >endlocal
    >:usrnf
    >@echo Syntax: PwdNX ons1 Y^|N - %ons1% NOT found.
    >endlocal
    >goto :EOF
    >:getusr
    >for /f "Tokens=2 Delims=: " %%a in ('adfind -b %ons1% -nodn -noctl
    >userAccountControl^|find /i "userAccountControl"') do (
    > set /a userAccountControl=%%a
    >)
    >goto :EOF
    >:updusr
    >admod -b %ons1% "userAccountControl::%userAccountControl%"
    >
    >
    >
    >this is what the results are:
    >the user name i am testing is ons1
    >
    >password never expires option is still not checked.
    >
    >and the cmd prompt shows the following
    >
    >i ran from cmd prompt
    >
    >c:\>pwdnvrx.bat
    >(this is the result)
    >c:\>setlocal
    >
    >c:\>if {} == {} goto err
    >syntax PwdNX ons1 Y:N
    >
    >c:\>endlocal
    >Syntax: PwdNX ons1 Y:N - NOT found.
    >
    >c:\>endlocal
    >
    >c:\>goto :EOF
    >
    >c:\>
    >
    >what have i messed up.
    >thanks for your help
    >brian metzger
    >
    >
    >
    >
    >>


    Are you being funny or just dense?

    1. DO NOT modify the batch file. Copy/Paste it just as it is.
    2. At the CMD.EXE prompt, type:
    pwdnx UserDN Y
    where UserDN is the distinguished name of ons1.

    Jerold Schulman
    Windows Server MVP
    JSI, Inc.
    http://www.jsiinc.com
    http://www.jsifaq.com

Similar Threads

  1. How to reset User Password via single user mode in mac os x
    By Jay Scott in forum Operating Systems
    Replies: 3
    Last Post: 10-11-2010, 07:00 PM
  2. List all users with 'Password Never Expires'
    By Tirana in forum Active Directory
    Replies: 4
    Last Post: 03-09-2009, 06:56 AM
  3. Replies: 1
    Last Post: 28-07-2008, 11:53 AM
  4. How to force User log off when time expires?
    By TheTurner in forum Windows Security
    Replies: 2
    Last Post: 28-07-2007, 06:32 AM
  5. Replies: 1
    Last Post: 28-04-2007, 08:57 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,993,894.81113 seconds with 16 queries