Hi<\/p>\n
Hoping someone can help with this script I have developed to remove all the members from a group without deleting the group. I think I have some kind of data conversion issue. Not an expert on PS so not sure what I should be doing now.<\/p>\n
Thanks in advance for your help.<\/p>\n
#Get<\/span> members of group #For<\/span> each memberin gorup { Getting this error<\/p>\n Cannot process argument transformation on parameter ‘Member’. Cannot convert value “joe.bloggs” to type<\/p>\n “Microsoft.Exchange.Configuration.Tasks.GeneralRecipientIdParameter”. Error: “Cannot convert hashtable to an object of the following type: Remove the -Whatif parameter after you’ve run this once and made sure it grabs the users you intended.<\/p>","upvoteCount":2,"datePublished":"2015-01-14T17:25:12.000Z","url":"https://community.spiceworks.com/t/script-to-remove-all-users-for-a-o365-group/370950/2","author":{"@type":"Person","name":"mattmcnabb","url":"https://community.spiceworks.com/u/mattmcnabb"}},"suggestedAnswer":[{"@type":"Answer","text":" Hi<\/p>\n Hoping someone can help with this script I have developed to remove all the members from a group without deleting the group. I think I have some kind of data conversion issue. Not an expert on PS so not sure what I should be doing now.<\/p>\n Thanks in advance for your help.<\/p>\n #Get<\/span> members of group #For<\/span> each memberin gorup { Getting this error<\/p>\n Cannot process argument transformation on parameter ‘Member’. Cannot convert value “joe.bloggs” to type<\/p>\n “Microsoft.Exchange.Configuration.Tasks.GeneralRecipientIdParameter”. Error: “Cannot convert hashtable to an object of the following type:
\n$objDGMembers = Get-DistributionGroupMember -Identity “Group Name”<\/p>\n
\nForeach ($objMember in $objDGMembers)<\/p>\n
\nRemove-DistributionGroupMember -Identity “Group Name” -Confirm:$False -Member $objMember
\n}<\/p>\n
\nMicrosoft.Exchange.Configuration.Tasks.GeneralRecipientIdParameter. Hashtable-to-Object conversion is not supported in restricted language mode or a Data section.”<\/p>\n\n
[Remove-DistributionGroupMember], ParameterBindin…mationException<\/li>\n
Get-DistributionGroupMember -Identity 'GroupName' | foreach {Remove-DistributionGroupMember -Identity 'GroupName' -Member $_.distinguishedname -whatif }\n<\/code><\/pre>\n
\n$objDGMembers = Get-DistributionGroupMember -Identity “Group Name”<\/p>\n
\nForeach ($objMember in $objDGMembers)<\/p>\n
\nRemove-DistributionGroupMember -Identity “Group Name” -Confirm:$False -Member $objMember
\n}<\/p>\n
\nMicrosoft.Exchange.Configuration.Tasks.GeneralRecipientIdParameter. Hashtable-to-Object conversion is not supported in restricted language mode or a Data section.”<\/p>\n