Home All Groups Group Topic Archive Search About

Net Add LocalGroup - question

Author
8 Aug 2005 9:45 PM
-
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.

Author
9 Aug 2005 9:26 AM
Giuseppe Nacci
- wrote:
Show quoteHide quote
> 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 supporto.informat***@degennaro.biz
Thank you
--------------------------------------------------------------------