I keep getting an error
Remove-ADGroupMember : Cannot bind parameter ‘Members’. Cannot create object of type “Microsoft.ActiveDirectory.Management.ADPrincipal”.
Please, when you post code or sample data or console output please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.
Thanks in advance
Since Remove-ADGroupMember takes an array of objects you don’t need a loop. But you should not limit the objects you provide to the name.
This should be all you need actually:
When you use the comparison operator -like you should provide a string containing an asterisk (*). Otherwise you should use -eq instead when you want to check for an exect match.