Remove-MsolGroupMember cmdlet ERROR

Welcome Forums General PowerShell Q&A Remove-MsolGroupMember cmdlet ERROR

This topic contains 5 replies, has 3 voices, and was last updated by

 
Participant
2 years, 6 months ago.

  • Author
    Posts
  • #40497

    Participant
    Points: 71
    Rank: Member

    Trying to remove a MSO groupmember for which it seems the cmdlet requires a GroupObjectId parameter however, the get-msolUser doesn't have it available from what I can tell.

     Remove-MsolGroupMember -GroupObjectId ecc923f7-480f-4b61-b0d1-05ddbadf0388 -GroupMemberType User -GroupMemberObjectId
    Remove-MsolGroupMember : Missing an argument for parameter 'GroupMemberObjectId'. Specify a parameter of type 'System.Nullable`1[System.Guid]' and try
    again.

    get-help -example also fail

  • #40503

    Participant
    Points: 0
    Rank: Member
    • #40736

      Participant
      Points: 71
      Rank: Member

      I was looking initially for a -properties * parameter like found in Get-ADUser but this exposed the objectID that I wasn't aware of

      Get-MsolUser -UserPrincipalName foof@company.com | fl objectid 
      ObjectId : 7f916f55-6690-4b1c-965b-ca7886dbc9bs 

      However, I still get an error from this code:

       Remove-MsolGroupMember -GroupObjectId ecc923f7-480f-4b61-b0d1-05ddbadf0384 -GroupMemberType User -GroupMem
      berObjectId 7f916f55-6690-4b1c-965b-ca7886dbc9bs
      Remove-MsolGroupMember : Unable to update parameter. Parameter name: . 
  • #40583

    Participant
    Points: 21
    Rank: Member

    You are missing an argument for the parameter -GroupMemberObjectId

    -GroupMemberObjectId 123456789

  • #41385

    Participant
    Points: 21
    Rank: Member

    get-help Remove-MsolGroupMember -Examples

    ————————– EXAMPLE 1 ————————–

    C:\PS>$groupId = Get-MsolGroup -searchString MyGroup
    $userid = get-msoluser -userPrincipalName user@contoso.com
    Remove-MsoLGroupMember -groupObjectId $groupid -GroupMemberType User -groupmemberobjectid $userid

  • #41676

    Participant
    Points: 71
    Rank: Member

    Hi Dan, Yes I tried that earlier before posting. I get this error

     Remove-MsolGroupMember : Cannot bind parameter 'GroupObjectId'. Cannot convert the
    "Microsoft.Online.Administration.Group" value of type "Microsoft.Online.Administration.Group" to type
    "System.Guid". 

The topic ‘Remove-MsolGroupMember cmdlet ERROR’ is closed to new replies.