Local Account Never Expire

you can use wmic

wmic path Win32_UserAccount WHERE Name="compte123" set PasswordExpires=false

Disable a local account

For enable

Net user Administrateur /active:Yes

For disable

Net user Administrateur /active:no

Ressource : http://www.windows-commandline.com/enable-disable-user-account-command/

Create a local account

Powershell

$Password = ConvertTo-SecureString "SuperPassword" -AsPlainText -Force
New-LocalUser "TempInstall" -Password $Password -FullName "TempInstall"
Add-LocalGroupMember -Group "Administrators" -Member "TempInstall" -ErrorAction SilentlyContinue
Add-LocalGroupMember -Group "Administrateurs" -Member "TempInstall" -ErrorAction SilentlyContinue
Set-LocalUser -Name "TempInstall" -PasswordNeverExpires 1

vbs

Function CreationCompte(strUser,strPass)
  Set Shell = WScript.CreateObject("WScript.Shell")
  CodeRetour = Shell.run("cmd /c net user " & strUser & " " & strPass & " /add",0,True)
  CodeRetour = Shell.run("cmd /c net localgroup " & chr(34) & "Administrateurs" & chr(34) & " " & strUser & " /add",0,True)

  Set objUser = Getobject("WinNT://" & "." & "/" & strUser)
  'Password never expires flag
  Flags = objUser.Get("UserFlags")
  objUser.put "Userflags", flags OR &H10000
  objUser.setinfo
End Function

0 Comments

Leave a Reply

Avatar placeholder

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.