Edit Net Accounts Info

Welcome Forums General PowerShell Q&A Edit Net Accounts Info

This topic contains 9 replies, has 2 voices, and was last updated by

 
Participant
3 years, 1 month ago.

  • Author
    Posts
  • #31363

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

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

  • #31371

    Participant
    Points: 0
    Rank: Member

    No Problem

  • #31373

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    is there a specific reason for using start-process?

    net.exe accounts /settings:value > null

  • #31377

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    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.

The topic ‘Edit Net Accounts Info’ is closed to new replies.