Groups and Users Management in Office 365 SharePoint Online via PowerShell

Open SharePoint Online Management Shell

Connect to your SharePoint Online site with your administrator access account
PS C:\Windows\system32> Connect-SPOService https://lcpsorg-admin.sharepoint.compowershellgroup2

Get list of groups. (Note: Some idiots panic unnecessarily when they don’t see the list of group names in the powershell window and see errors instead. Don’t be like those idiots and just verify that you specified URL of ‘site collection‘ and NOT the URL for the site.  Thanks, The idiot.)
PS C:\Windows\system32> Get-SPOSiteGroup -Site

What I wanted to do now is to get create a New SharePoint Online group in the site collection and set the permission for the group to ‘Approve

Setup script for new group:
PS C:\scripts\PowerShell Scripts> New-SPOSiteGroup -Site “User Id Approval Group” -PermissionLevels “Approve”

Adding user to the group:
PS C:\scripts\PowerShell Scripts> Add-SPOUser -Site -LoginName -Group “User Id Approval Group”

Verify that group is actually created and user added to group:
PS C:\scripts\PowerShell Scripts> Get-SPOSiteGroup -Site “User Id Approval Group”

This would then display the group with its attributes. For lack of time am gonna stop here. But there are ways to automate the process by scripting functions that would iterate through groups and get names from a CSV file

Pluralsight course – #Powershell for #Office 365


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s