Tag Archives: powershell office365

Sharepoint Online – Add members and owners via PowerShell

To add members and owners to a SharePoint Online TeamSite you have the below commands avaiable:

Note that if you need to make someone Owner of the Teamsite, the user first needs to be member! And then you make the user Owner.

#Get Credentials
$credObject = Get-Credential

#Connect to Exchange Online
$ExchOnlineSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $credObject -Authentication Basic -AllowRedirection

Import-PSSession $ExchOnlineSession

#Get Groupnames
Get-UnifiedGroup

#Check for current members
Get-UnifiedGroupLinks –Identity "groupname" –LinkType Members

#Check for current owners
Get-UnifiedGroupLinks –Identity "groupname" –LinkType Owners

#Add user as member
Add-UnifiedGroupLinks –Identity "groupname" –LinkType Members –Links info@iterrors.com

#Add user as owner (first make the user ‘member’)!!
Add-UnifiedGroupLinks –Identity "groupname" –LinkType Owner –Links info@iterrors.com

#Remove user as member
Remove-UnifiedGroupLinks –Identity "groupname" –LinkType Members –Links info@iterrors.com -Confirm:$false

#Remove user as Owner (Don’t forget to also remove the Members entry).
Remove-UnifiedGroupLinks –Identity "groupname" –LinkType Owners –Links info@iterrors.com -Confirm:$false

#Extra option, turn off the Welcome Message.
Set-UnifiedGroup "groupname" -UnifiedGroupWelcomeMessageEnabled:$false