none
Is it possible to remove spo-grid-all-users from a group with PowerShell?

    Question

  • I tried following commands:

    PS >$u = Get-SPOUser -Site "https://removed.sharepoint.com/sites/1" | Where-Object {$_.LoginName -like 'spo-grid-all-users/*'}

    PS >Remove-SPOUser -Site "https://removed.sharepoint.com/sites/1" -LoginName $u.LoginName 

    This fails with following error:

    Remove-SPOUser : Cannot complete this action.
    Please try again.
    At line:1 char:1
    + Remove-SPOUser -Site "https://removed.sharepoint.com/sites/1" -LoginNam ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Remove-SPOUser], ServerException
        + FullyQualifiedErrorId : Microsoft.SharePoint.Client.ServerException,Microsoft.Online.SharePoint.PowerShell.RemoveSPOUser

    Removing from the group does not work either:

    PS >Remove-SPOUser -Site "https://removed.sharepoint.com/sites/1" -LoginName $u.LoginName -Group "1 Members"

    Remove-SPOUser : The user does not exist or is not unique.
    At line:1 char:1
    + Remove-SPOUser -Site "https://removed.sharepoint.com/sites/1" -LoginNam ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Remove-SPOUser], ServerException
        + FullyQualifiedErrorId : Microsoft.SharePoint.Client.ServerException,Microsoft.Online.SharePoint.PowerShell.RemoveSPOUser

    I can remove Everyone except external users group from site and Members group here https://removed.sharepoint.com/sites/1/_layouts/15/people.aspx page with the same creds that I'm using in the PowerShell session. 

    Wednesday, November 23, 2016 1:01 PM

Answers

  • Hi,

    Try this:

    $loginName="c:0-.f|rolemanager|"+$u.LoginName
    write-host $loginName
    Remove-SPOUser -Site "https://xxx.sharepoint.com/sites/lee" -LoginName $loginName -Group "Lee-TeamSite Members"
    write-host done

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Thursday, November 24, 2016 4:58 AM

All replies

  • Hi,

    Try this:

    $loginName="c:0-.f|rolemanager|"+$u.LoginName
    write-host $loginName
    Remove-SPOUser -Site "https://xxx.sharepoint.com/sites/lee" -LoginName $loginName -Group "Lee-TeamSite Members"
    write-host done

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Thursday, November 24, 2016 4:58 AM
  • Thanks,

    That worked!

    Thursday, November 24, 2016 9:15 AM