Remove-PnPUserFromGroup -SharePoint Online (PnP Power Shell)


SharePoint/PnP-PowerShell has provide a great efforts to minimize code and increase productivity in SharePoint Online Development.

Recently we have to remove bulk amount of user from SharePoint Group. We decided to go with pnp power shell script to do it. As per the document Link РRemove User From Group below is the code.

Remove-PnPUserFromGroup -LoginName <String>
                        -Identity <GroupPipeBind>
                        [-Web <WebPipeBind>]
i.e.
PS:> Remove-PnPUserFromGroup -LoginName user@company.com -GroupName 'Marketing Site Members'



But above code didn't work. 

Actually we have to provide the -LoginName string like "i:0#.f|membership|user@contoso.com"
and its work.Below is the working script.
Remove-PnPUserFromGroup -LoginName "i:0#.f|membership|abdul.aziz@contoso.com" -GroupName 'Document'

 

 

Advertisements