Edit Net Accounts Info

This topic contains 9 replies, has 2 voices, and was last updated by Profile photo of Curtis Smith Curtis Smith 1 year, 8 months ago.

  • Author
    Posts
  • #31363
    Profile photo of ertuu85
    ertuu85
    Participant

    I don't think there is a native way through Powershell v2 to edit the values of

     Lockout observation window (minutes) 
     Lockout duration (minutes) 
     Length of password history maintained 
     Minimum password length 
     Lockout threshold 
     Minimum password age (days) 
     Maximum password age (days) 
    

    But is there a way using powershell to initiate other windows tools to edit these values (local values, not GPO)

    I see some options are available through the cmd

    NET ACCOUNTS
    [/FORCELOGOFF:{minutes | NO}] [/MINPWLEN:length]
                  [/MAXPWAGE:{days | UNLIMITED}] [/MINPWAGE:days]
                  [/UNIQUEPW:number] [/DOMAIN]
    

    But not all, is there a way to edit the values for:

    Lockout observation window (minutes)
    Lockout duration (minutes)
    Lockout threshold
    
  • #31365
    Profile photo of Curtis Smith
    Curtis Smith
    Participant

    You can still run the old command prompt commands in PowerShell. Look at the net accounts command

    C:\>net accounts /?
    The syntax of this command is:

    NET ACCOUNTS
    [/FORCELOGOFF:{minutes | NO}] [/MINPWLEN:length]
    [/MAXPWAGE:{days | UNLIMITED}] [/MINPWAGE:days]
    [/UNIQUEPW:number] [/DOMAIN]

  • #31366
    Profile photo of ertuu85
    ertuu85
    Participant

    Yeah, sorry was editting my original post to include that, do you know of a way to edit:

    Lockout observation window (minutes)
    Lockout duration (minutes)
    Lockout threshold

    I dont see those listed in the /?

  • #31368
    Profile photo of Curtis Smith
    Curtis Smith
    Participant

    Switches are there for those settings, /? just doesn't show them.

    http://www.vistax64.com/tutorials/182707-account-lockout-when-user-fails-logon-enable.html

  • #31369
    Profile photo of ertuu85
    ertuu85
    Participant

    Ah....thank you very much Curtis, you're always a huge help!

  • #31371
    Profile photo of Curtis Smith
    Curtis Smith
    Participant

    No Problem

  • #31373
    Profile photo of ertuu85
    ertuu85
    Participant

    Final question...I made it so it will change the settings based on desired settings using the following line:

    start-process -filepath net.exe -argumentlist "accounts /$($dvhash[$dvh][1]):$($dvhash[$dvh][2])"  -NoNewWindow -Wait -passthru | out-null
    

    With out-null it still shows

    The command completed successfully.
    

    I cant seem to find a way to suppress this message. I've tried out-null and 2>&1, anyone have an idea?

  • #31376
    Profile photo of Curtis Smith
    Curtis Smith
    Participant

    is there a specific reason for using start-process?

    net.exe accounts /settings:value > null

  • #31377
    Profile photo of ertuu85
    ertuu85
    Participant

    I suppose not really, just seemed more robust than net accounts /... but it works much better.

    Still displays if an error occurs such as 'The Parameter is incorrect' but it'll do. Thanks!

  • #31380
    Profile photo of Curtis Smith
    Curtis Smith
    Participant

    Technically all of those settings are registry entries. If you want to take the time to figure out which ones, you could just write to the registry value and bypass the commandline utility.

You must be logged in to reply to this topic.