Hello,
we added 1000 computers to a domain/AD. Bfore deployment they imaging guy created a local user with admin rights
just for administrative purposes. After distributing the computers, we realized that we need to delete/remove the account from all the computers. we do not want to go in every computer and delete the account. All the computers have already been added to the domain in their proper OU. My question is: can someone help me with a script that can delete the user from the local admin group. I know I can disable the account but I think I would be safer to delete the account. Any help will be greatly appreciated.
thands
Related:
Gpo delete local user account
Net localgroup administrators /remove - Best answers
You can write a VBscript that will remove a user from the local administrator group on all the pc in your domain. Then you set the script up to be a startup script in group policy and it will remove the user from every computers local admin group when the computer boots up. We also use this script to change the local administrator account's name and password. If the systems are Windows 2000 there are some AD dll's that have to be registered. If they are Windows XP, it will work with out any dll registration.
Sample....
Dim strLocalAdminGroup
Dim strComputer
Dim remadmins
Set WshShell = Wscript.CreateObject("Wscript.Shell")
Set WshSysEnv = WshShell.Environment("SYSTEM")
Set WshUserEnv = WshShell.Environment("User")
Set WshProEnv = WshShell.Environment("Process")
For I = lbound(remAdmins) to ubound(remAdmins)
Set grp = GetObject("WinNT://" & strComputer & "/" & strLocalAdminGroup)
member = "WinNT://" & remAdmins(i)
if grp.Ismember(member) = True then
grp.Remove(member)
end if
next
That script will also remove the local "everyone" group from the local administrators group. If the account is local then leave off the domain name and slash in the array.
If a user is an admin, he can remove 'himself' from admin group... why not use the command, on his account :
net localgroup administrators %username% /delete
You can launch that with GPO or a login script, or by SCCM.
What to do if a username or groupname are too long? For example I've got a trouble with removing a domain group from local group with in a command line? For example I'm
using next command (net localgroup "Administrator" "mydomn\uk-kre-workstation-adm" /delete) and it dosn't work, however I can to do this easely from mmc console, but question is how to run a selected task on more that 200 PC