General help and info provided by Helewix.com Consultants
| « Set Local Admin Password using .vbs (VB Script) and GPO | Logon VB Script to Create folder with shortcuts on Users Desktop and File Server » |
Remove Domain user from Local Administrators Group
You will just need to change YOURDOMAIN in the code below and then it will remove the current logged in domain user from the local administrators group.
Set WshS = WScript.CreateObject("WScript.Shell")
strComputer = WshS.ExpandEnvironmentStrings("%computername%")
strUser = WshS.ExpandEnvironmentStrings("%UserName%")
strDomain = "YOURDOMAIN"
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")
Set objUser = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
objGroup.Remove(objUser.ADsPath)
Please leave comments and let me know what you think of this code.