Net Add LocalGroup - question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I wanted to implement a script that would add a Domain Group into the local
Administrators group. It works fine, except that when it tries to place the
Domain Group into the local group and it's already present, it throws an
"error" saying that it's already present. I feel confident that this isn't
really an error per se, more just a piece of information, but I wanted to
see if there were a way in which I could avoid it. Perhaps there's batch
code that can check the membership of the group and then go to a different
line which would skip the process.

Is there such a thing?

Any info appreciated.

Thanks.
 
- said:
Hello,

I wanted to implement a script that would add a Domain Group into the
local Administrators group. It works fine, except that when it tries
to place the Domain Group into the local group and it's already
present, it throws an "error" saying that it's already present. I
feel confident that this isn't really an error per se, more just a
piece of information, but I wanted to see if there were a way in
which I could avoid it. Perhaps there's batch code that can check
the membership of the group and then go to a different line which
would skip the process.
Is there such a thing?

Any info appreciated.

Thanks.

You can do it by VBscript

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

If objGroup.Exists (objUser.ADsPath) Then
WScript.Echo "User already present."
Else objGroup.Add(objUser.ADsPath)
Wscript.Echo "Operation is done."
End If


This is only a idea I don't tested it.
--
---
Giuseppe Nacci
Microsoft Certified System Engineer
Security Manager

--------------------------------------------------------------------
CONFIDENTIALITY NOTICE
This message and its attachments are addressed solely to the persons
above and may contain confidential information. If you have received
the message in error, be informed that any use of the content hereof
is prohibited. Please return it immediately to the sender and delete
the message. Should you have any questions, please contact us by
replying to (e-mail address removed)
Thank you
--------------------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top