Re: Remove Users From Local Admin Group
From: Torgeir Bakken \(MVP\) (Torgeir.Bakken-spam_at_hydro.com)
Date: 01/19/05
- Next message: Sean M. Loftus: "Re: Script to format file to character number locations?"
- Previous message: emebohw2_at_netscape.net: "Re: how do I count only files in a folder with a specific extension?"
- In reply to: Forest: "Remove Users From Local Admin Group"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 19 Jan 2005 23:13:53 +0100
Forest wrote:
> Does anyone out there have a script that I can use in the login script to
> remove domain users from the local admin group? I want to lock down the
> local Admin group from the login script. Right now the domain user has admin
> access.
Hi
Below is a script that will remove all *user* accounts from the
Administrators group. Both local and domain users will be removed
(but not the builtin Administrator account). Any group accounts
will not be removed.
'--------------------8<----------------------
Set oWshNet = CreateObject("WScript.Network")
sComputer = oWshNet.ComputerName
' group to remove user from
Set oGroup = GetObject("WinNT://" & sComputer & "/Administrators")
' suppress errors, e.g. trying to remove the builtin Administrator
' account from the Administrators group will fail.
On Error Resume Next
' loop through all members of the Administrators group of type users
For Each oMember In oGroup.Members
If oMember.Class = "User" Then
' remove the user from Administrators group
oGroup.Remove oMember.ADsPath
End If
Next
'--------------------8<----------------------
-- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: http://www.microsoft.com/technet/scriptcenter/default.mspx
- Next message: Sean M. Loftus: "Re: Script to format file to character number locations?"
- Previous message: emebohw2_at_netscape.net: "Re: how do I count only files in a folder with a specific extension?"
- In reply to: Forest: "Remove Users From Local Admin Group"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|