Link to home
Start Free TrialLog in
Avatar of namerg
namergFlag for United States of America

asked on

How to add security group from another domain into Servers Local Administrator group's domain ?

Hello,
We have a domain with bunch of servers and they do not seem to have a security group part of their local administrator group in those servers.

I am wondering how to create a code where i can query all the servers and add the OtheDomain\SecurityGroup into the "Administrators" built-in group of the servers?

Thanks for your help,
Avatar of Shaun Vermaak
Shaun Vermaak
Flag of Australia image

Follow the steps in this article. You can use GPO Local Users and Groups preferences
https://www.experts-exchange.com/articles/29596/Securing-Active-Directory-Administrators-Groups.html
Avatar of namerg

ASKER

Hmm, if i am not allowed to create GPO ?
Avatar of SquigglyMonkey
SquigglyMonkey

Do you have an account that is member of the local administrators group on all the servers?
ASKER CERTIFIED SOLUTION
Avatar of SquigglyMonkey
SquigglyMonkey

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you want to use Powershell then use this one from the Microsoft ScriptCenter Gallery
###################################################################################### 
#             Author: Vikas Sukhija 
#             Date:- 08/30/2014 
#              Description:- This script will add user to local admin 
#                       on remote server.  
###################################################################################### 
 
#############ADD GUI Component###################################### 
 
function button ($title,$domain, $user, $Server) { 
 
[void][System.Reflection.Assembly]::LoadWithPartialName( "System.Windows.Forms")  
[void][System.Reflection.Assembly]::LoadWithPartialName( "Microsoft.VisualBasic")  
 
    $form = New-Object "System.Windows.Forms.Form"; 
    $form.Width = 500; 
    $form.Height = 150; 
    $form.Text = $title; 
    $form.StartPosition = [System.Windows.Forms.FormStartPosition]::CenterScreen; 
     
    $textLabel1 = New-Object "System.Windows.Forms.Label"; 
    $textLabel1.Left = 25; 
    $textLabel1.Top = 15; 
 
    $textLabel1.Text = $domain; 
 
    $textLabel2 = New-Object "System.Windows.Forms.Label"; 
    $textLabel2.Left = 25; 
    $textLabel2.Top = 50; 
     
    $textLabel2.Text = $user; 
 
    $textLabel3 = New-Object "System.Windows.Forms.Label"; 
    $textLabel3.Left = 25; 
    $textLabel3.Top = 85; 
  
    $textLabel3.Text = $Server; 
     
    $textBox1 = New-Object "System.Windows.Forms.TextBox"; 
    $textBox1.Left = 150; 
    $textBox1.Top = 10; 
    $textBox1.width = 200; 
 
    $textBox2 = New-Object "System.Windows.Forms.TextBox"; 
    $textBox2.Left = 150; 
    $textBox2.Top = 50; 
    $textBox2.width = 200; 
     
 
    $textBox3 = New-Object "System.Windows.Forms.TextBox"; 
    $textBox3.Left = 150; 
    $textBox3.Top = 90; 
    $textBox3.width = 200; 
     
    $defaultValue = "" 
    $textBox1.Text = $defaultValue; 
    $textBox2.Text = $defaultValue; 
    $textBox3.Text = $defaultValue; 
     
    $button = New-Object "System.Windows.Forms.Button"; 
    $button.Left = 360; 
    $button.Top = 85; 
    $button.Width = 100; 
    $button.Text = "Ok"; 
     
    $eventHandler = [System.EventHandler]{ 
    $textBox1.Text; 
    $textBox2.Text; 
    $textBox23.Text; 
    $form.Close();}; 
 
    $button.Add_Click($eventHandler) ; 
     
    $form.Controls.Add($button); 
    $form.Controls.Add($textLabel1); 
    $form.Controls.Add($textLabel2); 
    $form.Controls.Add($textLabel3); 
    $form.Controls.Add($textBox1); 
    $form.Controls.Add($textBox2); 
    $form.Controls.Add($textBox3); 
    $ret = $form.ShowDialog(); 
    return  $textBox1.Text, $textBox2.Text, $textBox3.Text 
} 
 
$return= button "Enter Parameters" "Enter Domain" "Enter User" "Enter Server" 
 
 
 
### Add Prameters returned from button  
$Domain = $return[0] 
$UserName = $return[1] 
$Computer = $return[2]  
 
## USe ADSI to connect to Remote Administrators group 
 
$Group = [ADSI]"WinNT://$Computer/Administrators,group" 
 
$User = [ADSI]"WinNT://$Domain/$UserName,user" 
 
$Group.Add($User.Path) 
 
if($error -ne $null) 
 { 
  (new-object -ComObject wscript.shell).Popup("$error",0,"Done",0x1) 
 } 
else 
 { 
 (new-object -ComObject wscript.shell).Popup("Operation Completed",0,"Done",0x1) 
  } 
 
##########################################################################################################

Open in new window

https://gallery.technet.microsoft.com/scriptcenter/Add-User-to-Local-964db4d0
Avatar of namerg

ASKER

Hmm, those script are asking to enter the servers manually. I need to query for the servers, read them and add the OtherDomain\Domain Admins into the "Administrators" local group of every server automatically.
Just checking...
Why not add OtherDomain\Domain Admins into Domain\Administrators group?
Avatar of namerg

ASKER

Hmm don't follow.... Domain\Administrators where ? In the domain controllers of the domain ?
There is a group called Administrators in both domains. This group is a Domain Local group.
There is a Domain Admins group in both domains. This group is a Global Security group.
You should be able to add Domain Admins from one domain into Administrators group on other domain.
This way you will have Administrators rights with Domain Admins to other domain's devices
Avatar of namerg

ASKER

Yeah, but that does not alleviate my RDP problem on every server in that domain. Remember there is Domain1\Domain Admins and Domain2\Domain Admins. Domain2 has bunch of servers. Those servers have "Administrators" local group. In order for me to RDP I have to add the Domain1\Domain Admins into the "Administrators" local group to every server in the domain2. Thanks,
That is incorrect. Domain2 domain Administrators group has Local Administrators rights on all Domain2 servers explicitly
Avatar of namerg

ASKER

Maybe, I am not following you. The attachment is domain2. Where do you want to add the Domain1\Domain Admins group to ?
Screenshot_5.png
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Accept: SquigglyMonkey (https:#a42446475)

If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

exchangepro
Experts-Exchange Cleanup Volunteer