none
Rename local administrator account on remote computers. RRS feed

  • Question

  • Hello All, 

    I need to rename the local administrator account on all my domain servers (Windows 2012, Windows 2008) to another name.  

    I have found the below script but not sure if it is good to use.  It would be ideal if the script can read a txt file that contains list of remote server names; this way I do not have to enter one at a time.  

    Please advise.  

    Thanks. 


    'Prompts you to enter a computer name
    strComputer = InputBox("Enter Computer Name")

    'Specify the current Administrator name
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colAccounts = objWMIService.ExecQuery _
        ("Select * From Win32_UserAccount Where LocalAccount = True And Name = 'Administrator'")

    'Specify the new Administrator name
    For Each objAccount in colAccounts
        objAccount.Rename "new_local_admin_name"
    Next
    Tuesday, March 20, 2018 6:33 PM

Answers

  • If you really need to do this (it doesn't really increase security), use the GPO setting.

    -- Bill Stewart [Bill_Stewart]

    Tuesday, March 20, 2018 6:36 PM
    Moderator

All replies

  • If you really need to do this (it doesn't really increase security), use the GPO setting.

    -- Bill Stewart [Bill_Stewart]

    Tuesday, March 20, 2018 6:36 PM
    Moderator
  • The GPO is easy and more powerful than trying to script this as it will rename accounts on newly joined systems automatically.


    \_(ツ)_/

    Tuesday, March 20, 2018 8:16 PM