Add domain user in Local Administrator Group

Today we are going to create a simple script that will help us to add domain users, into the local administrator's group via batch script.
Create a new notepad file and insert the below code into it. Once done save the notepad file with .bat or .cmd extension and place this file on the shared location and execute with psexec or PowerShell PSSession

Finally, your script will be looks like as shown in the above image✌

While running the script remotely we have to remove pause from the script and then execute the script.

















"Title Executed by Domain Administrators
REM ***********************************************************
REM*****Written by Dashrath Chate
REM*****Created Date 1:37 PM 9/19/2021
REM*****Purpose: To add domain user into
REM*****local administrators group remotly
REM************************************************************
@echo off
set %logfile% =%systemroot%\debug\larmgmtdomain.log
hostname
set DCname=%userdomain%>>%logfile%
set DCUserName=%username%>>%logfile%
net localgroup administrators /add %DCname%\%DCUserName%>>%logfile%"

No comments:

Post a Comment

Leave your valuable words here for improve better.