only returns members, not excluded members. This means that this cmdlet cannot be used to remove excluded members from a security group. I don't know how to access the appropriate parameter of the $_SecurityGroup object, otherwise I'd try to fix it myself and submit a pull request, sorry.
This command:
Invoke-XpathQuery -QueryMethod SelectSingleNode -Node $_SecurityGroup -query "child::member[objectId=
"$MemberMoref
"]"only returns members, not excluded members. This means that this cmdlet cannot be used to remove excluded members from a security group. I don't know how to access the appropriate parameter of the $_SecurityGroup object, otherwise I'd try to fix it myself and submit a pull request, sorry.