Remove "Everyone except external" from [Site Name] Members using PowerShell

%3CLINGO-SUB%20id%3D%22lingo-sub-2819952%22%20slang%3D%22en-US%22%3ERemove%20%22Everyone%20except%20external%22%20from%20%5BSite%20Name%5D%20Members%20using%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2819952%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20there%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20are%20using%20SharePoint%20Online%20and%20are%20looking%20for%20a%20way%20to%20programmatically%20move%20the%20%22Everyone%20except%20external%20users%22%20Group%20from%20the%20Site%20Members%20group%20to%20a%20newly%20created%20Contributors%20group.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20found%20a%20way%20to%20remove%20specific%20users%20from%20the%20Members%20group%20in%20the%20following%20command%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3ERemove-SPOUser%20-LoginName%20%22user%20login%20name%22%20-Site%20%24Site%20-Group%20%22Site%20Name%20Members%22%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EHowever%2C%20when%20I%20list%20the%20Members'%20members%2C%20I%20am%20shown%20that%20%22Everyone%20except%20external%20users%22%20is%20listed%20as%20%3CSTRONG%3Espo-grid-all-users%2F%5Bguid%20here%5D%3C%2FSTRONG%3E.%20And%20then%20when%20I%20try%20and%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3ERemove-SPOUser%20-LoginName%20%22spo-grid-all-users%2Fguid%22%20...%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EI%20am%20presented%20with%20%22The%20user%20does%20not%20exist%20or%20is%20not%20unique.%22%3C%2FP%3E%3CP%3EWe%20do%20know%20how%20to%20do%20this%20from%20GUI%2C%20but%20how%20do%20we%20remove%20the%20%22Everyone%20except%20external%20users%22%20from%20the%20Site%20Members%20group%20with%20PowerShell%20and%20then%20add%20them%20the%20new%20group%20we%20created%20with%20Contributor%20permissions.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%2C%3C%2FP%3E%3CP%3EJames%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2819952%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPermissions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Frequent Visitor

Hello there,

 

We are using SharePoint Online and are looking for a way to programmatically move the "Everyone except external users" Group from the Site Members group to a newly created Contributors group.

 

I have found a way to remove specific users from the Members group in the following command:

Remove-SPOUser -LoginName "user login name" -Site $Site -Group "Site Name Members"

However, when I list the Members' members, I am shown that "Everyone except external users" is listed as spo-grid-all-users/[guid here]. And then when I try and 

Remove-SPOUser -LoginName "spo-grid-all-users/guid" ...

I am presented with "The user does not exist or is not unique."

We do know how to do this from GUI, but how do we remove the "Everyone except external users" from the Site Members group with PowerShell and then add them the new group we created with Contributor permissions.

 

Thank you,

James

0 Replies