Add computer in one forest to a group in another

I have a two way trust between two forests and I am trying to bulk add systems from one forest to a group in another forest. When I run the below code, I get “Add-ADGroupMember : The server is unwilling to process the request”

Below is the script I am using. The CSV is formatted as:

Computer Group

ComputerinForestA$ GroupInForestB

Set-ExecutionPolicy bypass

$Credential = Get-Credential

Import-Module ActiveDirectory

$CSV=Import-csv -path ‘C:PATHAD-AddComputerToSecurityGroup-csv.csv’

$ForestAgroup = Get-ADGroup $CSV.Group -server Server1.ForestA:3268

$ForestBComputers = Get-ADComputer $CSV.Computer -server Server1.ForestB:3268

ForEach ($Computer in $CSV){

Add-ADGroupMember -Identity $ForestAgroup -members $ForestBComputers}

submitted by /u/TheBlackArrows
[link] [comments]

Leave a Reply