Kaseya Community

Create local admin with no password expry

  • So I've been running this script and variants of since I've started with Kaseya. The original scripts and vbs files can be found here and here.



    Long story short, the bit that runs the vbs file to make the password not expire is not working. It doesn't generate an error nor does it fail the step. It just doesn't work.



    I can only assume that it has something to do with K2 as it worked while using K2k8.



    Below is the script and the vbs file



























    " />









    " />





























































































    '==============================================================================

    ' nopwdexp.vbs

    ' Windows NT/2000/XP/2003 Administration Script

    '

    ' Turns off password expiry for the specified account

    '

    ' Usage: cscript //nologo nopwdexp.vbs /domainBig Smileomainname /user:username

    '

    ' Written by Mark Wilson, 10 September 2004

    '

    ' This script is provided as is without warranty of any kind. Mark Wilson

    ' further disclaims all implied warranties including, without limitation, any

    ' implied warranties of merchantability or of fitness for a particular purpose.

    ' The entire risk arising out of the use or performance of the script including

    ' any associated documentation remains with the user of the script.

    ' ==============================================================================



    Option Explicit



    On Error Resume Next



    ' Set constants

    Const ufDONT_EXPIRE_PASSWD = &H10000



    ' Set variables

    Dim colNamedArguments

    Dim strDomain, strUser



    ' Read command line named arguments

    Set colNamedArguments = WScript.Arguments.Named



    ' Report missing domain argument

    If colNamedArguments.Exists("domain") Then

    strDomain=colNamedArguments.Item("domain")

    Else

    WScript.Echo "Missing argument: /domainBig Smileomainname"

    Usage

    End If



    ' Report missing user argument

    If colNamedArguments.Exists("user") Then

    strUser=colNamedArguments.Item("user")

    Else

    WScript.Echo "Missing argument: /user:username"

    Usage

    End If



    PasswordNeverExpires strDomain, strUser



    ' ******************************************************************************



    Sub PasswordNeverExpires(domainname, username)

    ' Sets the do not expire password flag if not already set



    Dim objUser, objUserFlags



    ' Read user properties

    Set objUser = GetObject("WinNT://" & domainname & "/" & username & ",user")



    ' Examine flags set against account

    objUserFlags = objUser.Get("UserFlags")



    ' If password expiry is allowed, then set password never to expire.

    If (objUserFlags And ufDONT_EXPIRE_PASSWD) = 0 Then

    ' Password does expire

    ' WScript.Echo objUserFlags

    objUserFlags = objUserFlags Or ufDONT_EXPIRE_PASSWD

    ' WScript.Echo objUserFlags

    objUser.Put "UserFlags", objUserFlags

    objUser.SetInfo

    WScript.Echo domainname & "\" & username & " password has been set never to expire."

    Else

    ' Password does not expire

    ' WScript.Echo objUserFlags

    WScript.Echo domainname & "\" & username & " password was already set never to expire."

    End If



    End Sub



    ' ******************************************************************************



    Sub Usage()

    ' Reports the correct command line syntax



    Wscript.Echo VbCr

    WScript.Echo "nopwdexp.vbs"

    Wscript.Echo VbCr

    WScript.Echo "Usage: cscript //nologo nopwdexp.vbs /domainBig Smileomainname /user:username"

    Wscript.Quit



    End Sub



    ' ******************************************************************************





    *Please note: the second and third steps defines a variable you should change;



    also worth noting is that if I add the /comment:#comment# option the command will not work :sad: but that'll be for another thread.



    Edit: I've tried running that command as system, user and impersonate user. All with the same result... If I do the command from CLI it works.

    Legacy Forum Name: Create local admin with no password expry,
    Legacy Posted By Username: thirteentwenty
  • The following line of code is what I use to set the pwd to never expire.
    Just select Execute Shell Command and paste this in.
    Select Execute as system account.

    wmic path Win32_UserAccount where Name='username' set PasswordExpires=false

    Legacy Forum Name: Kaseya2 Scripts,
    Legacy Posted By Username: ar3030
  • ar3030
    The following line of code is what I use to set the pwd to never expire.
    Just select Execute Shell Command and paste this in.
    Select Execute as system account.

    wmic path Win32_UserAccount where Name='username' set PasswordExpires=false


    Unfortunately that doesn't work with domain accounts - only local accounts.

    Andrew

    Legacy Forum Name: Kaseya2 Scripts,
    Legacy Posted By Username: andrew.doull@computer-care.com.au
  • But it comes in handy for establishing a local hidden admin account on an agent in a script.

    K2 is supposed to create/set an account to non-expiring through the RemoteControl/Reset Password. Seems to work for me for domain accounts.

    Legacy Forum Name: Kaseya2 Scripts,
    Legacy Posted By Username: smbtechnology
  • smbtechnology
    But it comes in handy for establishing a local hidden admin account on an agent in a script.

    K2 is supposed to create/set an account to non-expiring through the RemoteControl/Reset Password. Seems to work for me for domain accounts.


    I've just done some limited testing on our test machines and it seems to fail on vista/7 machines, but passes on XP machines for the most part...

    I do get the bellow error (fails on the domain side of things)
    [QUOTE=ERROR]
    C:\Documents and Settings\badadmin>wmic path Win32_UserAccount where Name='badadmin' set PasswordExpires=false
    Updating property(s) of '\\GIMP\root\cimv2:Win32_UserAccount.Domain="GIMP",Name="badadmin"'
    Property(s) update successful.
    Updating property(s) of '\\GIMP\root\cimv2:Win32_UserAccount.Domain="TESTDOMAIN",Name="badadmin"'
    ERROR:
    Code = 0x80041001
    Description = Generic failure
    Facility = WMI
    [/quote]

    Legacy Forum Name: Kaseya2 Scripts,
    Legacy Posted By Username: thirteentwenty
  • I have not tested on Vista, but is does work on Windows 7.

    Legacy Forum Name: Kaseya2 Scripts,
    Legacy Posted By Username: ar3030