Office 365 – Powershell script to change a groups ownership with Set-DistributionGroup

The below script with change the owner of a group, giving the new owner admin rights to the group.

Connecting to Office 365

$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session

Changing the group owner using Set-DistributionGroup

Change the GroupAlias and NewOwnersEmailAddress to the relevant values.

Set-DistributionGroup "GroupAlias" -ManagedBy "NewOwnersEmailAddress" -BypassSecurityGroupManagerCheck

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.