Jump to content

Substitute for net localgroup


Recommended Posts

  • Moderators

You can always go the old WinNT route, works on Win7 and Win10:

Local $oGroup = ObjGet("WinNT://" & @ComputerName & "/Administrators")
    If IsObj($oGroup) Then
        $oGroup.Add("WinNT://" & @ComputerName & "/MyReallyCoolSuperLongYoureNotGoingToBelieveHowAwesomeThisGroupIs Group")
    Else
        ConsoleWrite("Could not obtain object." & @CRLF)
    EndIf

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

JLogan3o13,

 

Sorry for my ignorance, but what does the above script do? I performed it and saw no result whatsoever.



How could I replace the commands below?

 

net localgroup <local group> /add <domain\domain group>

net localgroup <local group> /delete <domain\domain group>

Link to comment
Share on other sites

Make sure you add #RequireAdmin to the top of the script otherwise it will error, but basically it will add a user to the local group another example, adding "Authenticated Users" to "Power Users" group.

#RequireAdmin
Local $oGroup = ObjGet("WinNT://" & @ComputerName & "/Power Users")
If IsObj($oGroup) Then
    $oGroup.Add("WinNT://" & @ComputerName & "/Authenticated Users")
Else
    ConsoleWrite("Could not obtain object." & @CRLF)
EndIf

 

Link to comment
Share on other sites

Subz,

 

I ran the above script to add the domain group "TRT2R\RDP" to the local group "Administradores", but I got the error below:

 

2018-05-29_134126.thumb.jpg.a2235725b0b46f92d18be92e9ecf2b6a.jpg

 

But by the net localgroup I can do the same action.:

 

2018-05-29_134222.jpg.4e1adc3878f20e8c57298ed985c5f16d.jpg

Link to comment
Share on other sites

Now it worked. But how do I prevent the script from being aborted when an error occurs (if the group is already added or not able to communicate with the domain server, for example)?

Link to comment
Share on other sites

  • Moderators

Well, if to add it you need to do

$oGroup.Add

What might you think you would need to do to remove?

This forum is dedicated to helping, not spoon-feeding it to you; you have to show at least some level of effort.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...