General help and info provided by Helewix.com Webmasters

« Set Local Admin Password using .vbs (VB Script) and GPOLogon VB Script to Create folder with shortcuts on Users Desktop and File Server »

Manage Local Groups using VBS

10/08/10 | by Helewix.com Webmaster [mail] | Categories: Scripting

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.

Plutus Hosting - Quality and Affordable Website and Email Hosting

Property Pimp

Permalink

Trackback address for this post

This is a captcha-picture. It is used to prevent mass-access by robots.
Please enter the characters from the image above. (case insensitive)

No feedback yet

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
PoorExcellent
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)
This is a captcha-picture. It is used to prevent mass-access by robots.
Please enter the characters from the image above. (case insensitive)
General help and info provided by Helewix.com Webmasters
May 2012
Sun Mon Tue Wed Thu Fri Sat
 << <   > >>
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

Blogger Rating

Ads

Plutus Hosting - Quality and Affordable Website and Email Hosting
usafis
Loanfinder SA
AreYouInterested

WiCount

Listing4me

MarisIT

Search

Flag Counter

free counters

XML Feeds

powered by b2evolution