Hi, I get this error when trying to remove members in a distribution group with a PowerShell script
… Remove-DistributionGroupMember -Identity $GroupName -Member $_ -Con … | ~~~~~~~ | A parameter cannot be found that matches parameter name 'Member'.
The code to remove is this
$Members_To_Remove |
foreach {
if ( !$DryRun ) {
Remove-DistributionGroupMember -Identity $GroupName -Member $_ -Confirm:$false
}
Write-Host -ForegroundColor red "$_ User removed in Distribution Group $Grupname"
}
}
The code to add works fine, I can add members.
$Members_To_Add |
foreach {
if ( !$DryRun ) {
Add-DistributionGroupMember -Identity "$GroupName" -Member $_
}
Write-Host -ForegroundColor green "Added User $_ in $GroupName as Member"
}
It seems that the parameter member is not in the remove command
get-command -name Remove-DistributionGroupMember | Fl *
HelpUri : https://docs.microsoft.com/powershell/module/exchange/remove-distributiongroupmember
ScriptBlock :
[CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='High')]
param(
[Parameter(ParameterSetName='Identity', Mandatory=$true, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
${Identity}
)
Begin {
$CmdletRequestId = [System.Guid]::NewGuid().ToString()
....
But it is in add command
HelpUri : https://docs.microsoft.com/powershell/module/exchange/add-distributiongroupmember
ScriptBlock :
[CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Medium')]
param(
[Parameter(ParameterSetName='Identity', Mandatory=$true, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
${Identity},
[Parameter(ValueFromPipeline=$true)]
[ValidateNotNull()]
${Member} #<----- Here
)
Begin {
$CmdletRequestId = [System.Guid]::NewGuid().ToString()
....
could it be related to a permission problem?
Juan