Ron Shorts
asked on
Foreach statement to copy unified group members
Looking for help in getting input from a .csv file for copying group members from one group to another. Both are Unified groups.
This code works for a single group to group copy:
This is what I setup in for foreach:
Error I'm getting is:
Cannot bind argument to parameter 'Identity' because it is null.
+ CategoryInfo : InvalidData: (:) [Get-UnifiedGroupLinks], ParameterBindingValidation Exception
+ FullyQualifiedErrorId : ParameterArgumentValidatio nErrorNull NotAllowed ,Get-Unifi edGroupLin ks
+ PSComputerName : outlook.office365.com
GroupInput.csv:
SourceGroup,TargetGroup
Group1,Group2
This code works for a single group to group copy:
$List = Get-UnifiedGroupLinks -Identity "Group1" -LinkType Members | Select-Object -expandproperty name
Add-UnifiedGroupLinks -Identity "Group2" -LinkType Members -Links $List
This is what I setup in for foreach:
$Groups = Import-Csv -Path .\GroupInput.csv
foreach ($Group in $Groups) {
$List = Get-UnifiedGroupLinks -Identity $_.SourceGroup -LinkType Members | Select-Object -expandproperty name
Add-UnifiedGroupLinks -Identity $_.TargetGroup -LinkType Members -Links $List
}
Error I'm getting is:
Cannot bind argument to parameter 'Identity' because it is null.
+ CategoryInfo : InvalidData: (:) [Get-UnifiedGroupLinks], ParameterBindingValidation
+ FullyQualifiedErrorId : ParameterArgumentValidatio
+ PSComputerName : outlook.office365.com
GroupInput.csv:
SourceGroup,TargetGroup
Group1,Group2
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.