Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Create Local Group on remote servers

$
0
0

Guys,

I have put together below script (thanks to everyone for posting great scripts). I have copied some part of the script from the forum examples.

This script will take Input, create Domain group and add that domain group to the number of member servers listed in the text file.

So far so good, my this script works fine. 

Question - I need to add functionality in the script to create new local group on member servers using same variable and Add the Domain group (created using same variable) in the newly created local group on member servers.

 

I also want to have an output file for the failed hosts. 

Appreciate your help.

==============================================
# input
$Name = Read-Host "Write Policy Name"


#Create Domain User Group
NEW-ADGroup -Name ${Name}_UserGroup –groupscope Global -path "ou=Test,DC=Lab,DC=Local" -Description "${Name} Domain users Group"

#Read Servers from the Text File
$Servers = Get-Content c:\temp\${Name}_Servers.txt

#Initialize the Domain Group Object 
$DomainGroup = [ADSI]"WinNT://Lab.local/${Name}_usergroup,group"


#Add Domain group to the local Remote Desktop Group on member servers
ForEach ($Server in $Servers) #Loop through each server 


    
    #Get Local Group object 
    $LocalGroup = [ADSI]"WinNT://$Server/Remote Desktop Users,group" 
 
    #Assign DomainGroup to LocalGroup 
    $LocalGroup.Add($DomainGroup.Path)
   
}

==============================


Viewing all articles
Browse latest Browse all 6937

Trending Articles