I am trying to copy group membership from one user to another in AD using Powershell. I get the error below. Can't seem to figure it out.
Get-ADUser -server "test.server.com" -Identity user11 -Properties memberof |
Select-Object -ExpandProperty memberof
Add-ADGroupMember -Member user22
The error I receive is
Add-ADGroupMember : Parameter cannot be processed because the parameter name 'Member' is ambiguous. Possible matches include:
-Members
-MemberTimeToLive. At line:3 char:19
+ Add-ADGroupMember -Member user22
+ ~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Add-ADGroupMember], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameter,Microsoft.ActiveDirectory.Management.Commands.AddADGroupMember
So lets talk about what the error Ambiguous means.
In Powershell you can write short hand
Get-ChildItems -path C:\Test
is the same as
Get-ChildItems -pat C:\Test
If we look at the documentation from Microsoft on Add-AdGroupMember
We can see that the command has 2 parameters with Member in it -MemberTimeToLive and -Members
What the error means is it doesnt know if -Member is you calling -Members or -MemberTimeToLive
This is called Ambiguous
The fix would be
Add-ADGroupMember -Members user22
The error message is very clear. PowerShell does partial matching of parameter names, and will accept a partial parameter name if it is sufficient to be uniquely identifiable. In your case, the partial parameter -Member does not match uniquely; it could be referring to either -Members or -MemberTimeToLive. To fix it, you should use -Members instead of -Member.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With