Jump to content
Darien

Substitute for net localgroup

Recommended Posts

JLogan3o13

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

 


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Darien

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>

Share this post


Link to post
Share on other sites
Subz

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

 

Share this post


Link to post
Share on other sites
Darien

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

Share this post


Link to post
Share on other sites
Darien

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)?

Share this post


Link to post
Share on other sites
JLogan3o13

We call it Error Checking. Look at @error in the help file, or search on the forum.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Darien

OK. And to remove a group, how do I do?

Share this post


Link to post
Share on other sites
JLogan3o13

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.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Darien

I tried with del, delete and remove and it did not work.

Share this post


Link to post
Share on other sites
AdamUL

Have a look at the Local Account UDF.  Look through the thread for additional functions.  

 

Adam

Share this post


Link to post
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

×