Create an account that never expires and is a member of the Local administrators group from the command line

Written by James McDonald

October 9, 2023

In an Administrative cmd or powershell terminal run

# /expires:never sets account to never expire NOT password
net user toggenator2 * /add /expires:never

# Password never expires 
wmic UserAccount where Name="toggenator" set PasswordExpires=False
# or use powershell
Get-LocalUser toggenator | Set-LocalUser -PasswordNeverExpires $true
# Add to Administrators Powershell/cmd
Add-LocalGroupMember -Member toggenator -Group Administrators
net localgroup Administrators toggenator /add

To confirm

net user toggenator

Output of net user command

User name                    toggenator
Full Name
Comment
User's comment
Country/region code          000 (System Default)
Account active               Yes
Account expires              Never

Password last set            5/07/2024 12:34:28 PM
Password expires             Never
Password changeable          5/07/2024 12:34:28 PM
Password required            Yes
User may change password     Yes

Workstations allowed         All
Logon script
User profile
Home directory
Last logon                   Never

Logon hours allowed          All

Local Group Memberships      *Administrators       *Users
Global Group memberships     *None
The command completed successfully.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.

You May Also Like…

Robocopy exclude Directories

Just trying to copy everything except a couple of directories from a drive to my NAS This is the secret incantation of...