Today we are going to create a simple script that will help us to remove domain users from 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.
While running the script remotely we have to remove pause from the script and then execute the script.
Finally, your script will be looks like as below ✌
"Title Executed by Domain Administrators
REM ***********************************************************
REM*****Written by Dashrath Chate
REM*****Created Date 3:27 PM 7/05/2018
REM*****Purpose: To Remove domain user from
REM*****local administrators group remotly
REM************************************************************
@echo off
hostnamenet localgroup administrators <DomainName1>\<User Name1> /delete
net localgroup administrators <DomainName2>\<User Name1> /delete
###########################################
Pause
No comments:
Post a Comment
Leave your valuable words here for improve better.