Good Afternoon,
I'm trying to run script you provided about 4 years agao
$DGs=Get-DistributionGroup|where{(Get-DistributionGroupMember $_|foreach{$_.PrimarySmtpAddress})-contains "user@domain.com"}
foreach( $dg in $DGs){
Remove-DistributionGroupMember $dg-Member user@domain.com
}
But I get an error when I try to run. I do understand that there is programming script error but I don't know how to fix it.
I'm trying to remove a user from multiple distribution lists by using your script. My environment does not have AD integration at this time.
I get the error msg below when I try to run your script.
Cannot process argument transformation on parameter 'Identity'. Cannot convert
value "ACCESS U.S. Help Desk" to type
"Microsoft.Exchange.Configuration.Tasks.DistributionGroupMemberIdParameter".
Error: "Cannot convert hashtable to an object of the following type:
Microsoft.Exchange.Configuration.Tasks.DistributionGroupMemberIdParameter.
Hashtable-to-Object conversion is not supported in restricted language mode or
a Data section."
+ CategoryInfo : InvalidData: (:) [Get-DistributionGroupMember],
ParameterBindin...mationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-Distrib
utionGroupMember
+ PSComputerName : pod51048psh.outlook.com
Any help would be greatly appreciated
Darren