Groups and Users Management in Office 365 SharePoint Online via PowerShell

Open SharePoint Online Management Shell
powershellgroup1

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 https://lcpsorg.sharepoint.com/sites/formspowershellgroup3.png

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 https://xyz.sharepoint.com/sites/abc-Group “User Id Approval Group” -PermissionLevels “Approve”

Adding user to the group:
PS C:\scripts\PowerShell Scripts> Add-SPOUser -Site https://lcpsorg.sharepoint.com/sites/forms -LoginName joe.healy@contoso.com -Group “User Id Approval Group”

Verify that group is actually created and user added to group:
PS C:\scripts\PowerShell Scripts> Get-SPOSiteGroup -Site https://xyz.sharpeoint.com/sites/abc-Group “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

References:
Pluralsight course – #Powershell for #Office 365

 

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s