Jump to content

Recommended Posts

Posted

Hi,

 

it has just come to my attention, that on the last image i have just rolled out to a couple of ict suites. that I left the local testing account as an administrator.

 

I need to change this pronto, does anyone have any scripts, batch or vbs that can be run.

 

Need to change the account called "ecdl" from being a administrator to a standard user.

 

Cheers,

 

Michael

Posted

This is easy in VBS, have a look here:

Remove Unapproved Local Administrators [vbScript] - Altirigos

 

' Remove Unapproved Local Administrators.
'vbscript

'** Written By:
'**   Dane Jones

'** Define Variables
   Dim PermittedAdmins' As Array
   
'** Define Permited Administrators List
   PermittedAdmins = Array("Administrator", "Domain Admins") '<--- Add to this Array any additional permited admins

'** Get Local Administrator Group
   Set AdminGroup = GetObject("WinNT://./Administrators, Group")

'** Search for Invalid Members & Remove Them
   For Each GroupMember in AdminGroup.Members
   
       Debug.WriteLine GroupMember.Name, GroupMember.Class, IsPermitedAdmin(GroupMember.Name)
   
       If Not IsPermitedAdmin(GroupMember.Name) Then
           AdminGroup.Remove GroupMember.ADsPath
       End If
   Next

'** Functions *****************************************************************
   Function IsPermitedAdmin(MemberName)' As Boolean
       Dim i' As Long
       
       For i = LBound(PermittedAdmins) To UBound(PermittedAdmins)
           If UCase(MemberName) = UCase(PermittedAdmins(i)) Then
               IsPermitedAdmin = True
               Exit Function
           End If
       Next
       
       IsPermitedAdmin = False
   End Function

  • Thanks 1
Posted

Thats also doable, check out here for a rundown on some of the common operations for local accounts: Scripting Local Groups using VBScript

 

Adds a user (kenmyer) to the local Administrators group on a computer named MyComputer.

strComputer = "MyComputer"
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")
Set objUser = GetObject("WinNT://" & strComputer & "/kenmyer,user")
objGroup.Add(objUser.ADsPath)

 

just change strComputer = "MyComputer" to strComputer = "." to make it run on the local computer rather than going after a specific box over the network.

  • Thanks 1
Posted

Cheers SYNACK...

 

Unfortunately i couldn't get that script to run... did manage to get a batch file to do what I wanted...

 

net localgroup "Power Users" "ecdl" /add

 

Michael

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...