I want to know how to create a users group in Office 365 Admin using PowerShell. Is there a possibility to add this group to TermStore Administrators and TermSet Contributor - Through Powershell only.
Thanks
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityI want to know how to create a users group in Office 365 Admin using PowerShell. Is there a possibility to add this group to TermStore Administrators and TermSet Contributor - Through Powershell only.
Thanks
You could consider the following options for creating a Group:
New-SPOSiteGroup cmdlet creates a new group in a SharePoint Online site collection, for example:
Connect-SPOService -Url https://contoso-admin.sharepoint.com -credential admin@contoso.com
New-SPOSiteGroup -Site https://contoso.sharepoint.com/sites/siteA -Group "Project Leads" -PermissionLevels "Full Control"
How to create SharePoint Group using CSOM in PowerShell:
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime")
Function Get-SPOCredentials([string]$UserName,[string]$Password)
{
$SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force
return New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $SecurePassword)
}
Function Create-SPOGroup([Microsoft.SharePoint.Client.ClientContext]$Context,[string]$Title,[string]$Description)
{
$info=New-Object Microsoft.SharePoint.Client.GroupCreationInformation
$info.Title=$Title
$info.Description=$Description
$group=$Context.Web.SiteGroups.Add($info)
$Context.ExecuteQuery()
}
Usage
$UserName = "username@contoso.onmicrosoft.com"
$Password = Read-Host -Prompt "Enter the password"
$Url = "https://contoso.sharepoint.com/"
$context = New-Object Microsoft.SharePoint.Client.ClientContext($Url)
$context.Credentials = Get-SPOCredentials -UserName $UserName -Password $Password
Create-SPOGroup -Context $context -Title "Foo" -Description ""
$context.Dispose()
Regarding adding TermStore Administrators, AFAIK it is only supported via Server Side Object Model using TermStore.AddTermStoreAdministrator method