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,
namergSystems AdministratorAsked:
Who is Participating?
 
SquigglyMonkeyCommented:
If so, this should be what you need, it is a script from Microsoft.
https://gallery.technet.microsoft.com/scriptcenter/Add-AD-UserGroup-to-Local-fe5e9239
0
 
Shaun VermaakTechnical Specialist/DeveloperCommented:
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
1
 
namergSystems AdministratorAuthor Commented:
Hmm, if i am not allowed to create GPO ?
0
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

 
SquigglyMonkeyCommented:
Do you have an account that is member of the local administrators group on all the servers?
0
 
Shaun VermaakTechnical Specialist/DeveloperCommented:
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
0
 
namergSystems AdministratorAuthor Commented:
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.
0
 
Shaun VermaakTechnical Specialist/DeveloperCommented:
Just checking...
Why not add OtherDomain\Domain Admins into Domain\Administrators group?
0
 
namergSystems AdministratorAuthor Commented:
Hmm don't follow.... Domain\Administrators where ? In the domain controllers of the domain ?
0
 
Shaun VermaakTechnical Specialist/DeveloperCommented:
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
0
 
namergSystems AdministratorAuthor Commented:
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,
0
 
Shaun VermaakTechnical Specialist/DeveloperCommented:
That is incorrect. Domain2 domain Administrators group has Local Administrators rights on all Domain2 servers explicitly
0
 
namergSystems AdministratorAuthor Commented:
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
0
 
Jason CrawfordTransport NinjaCommented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.