3 minutes reading time (545 words)

Remove Yammer licenses in Office 365 using PowerShell

UPDATED July 2023. How to remove Office 365 Yammer and Viva Engage licenses using PowerShell Set-MsolUserLicense. Find the right Office 365 product SKU and license plan name. Get the status of disabled Yammer licenses and re-enable all disabled license plans.

Remove Yammer licenses using PowerShell

To remove Yammer licenses using PowerShell you'll need to define a new license plan that has Yammer disabled, then apply the license plan to a user account

To define a license plan, you'll need to get the Office 365 product SKU and the Yammer service plan

Get Office 365 Product SKU using PowerShell

# Connect to Azure AD

# Get Account Sku Id
Get-MsolAccountSku | Select AccountSkuId 

Office 365 product SKUs

Microsoft 365 Business premium

Microsoft 365 Enterprise e3

Get all license plans using PowerShell Get-MsolAccountSku

A license plan is all the M365 services that are available to users

# Get license plans
Get-MsolAccountSku | Select -ExpandProperty ServiceStatus  

Get license plan status for a user with PowerShell Get-MsolUser

$user = "Bender@planetxpress.net"
(Get-MsolUser -UserPrincipalName $user).licenses.ServiceStatus 

In this example, the Yammer license is enabled for the user account

Get licence plans by name for a user with PowerShell

# Get license plans named Yammer or Viva
$user = "Bender@planetxpress.net"
(Get-MsolUser -UserPrincipalName $user).licenses.ServiceStatus | Where-Object { $_.ServicePlan.ServiceName -like '*Yammer*' -or  $_.ServicePlan.ServiceName -like '*Viva*'} 

Disable Yammer and Viva Engage licenses for a user with PowerShell Set-MsolUserLicense

# define variables for user, licenses and Office 365 product SKU
$user = "Bender@planetxpress.net"
$licenses = (Get-MsolUser -UserPrincipalName $user).Licenses
$AccountSkuId = "planetxpressnet:SPB"

# Get existing disabled licenses plus Yammer and Viva Engage core licenses, add to array
ForEach ($License in $Licenses) {
$disabledplans = @()
$License.ServiceStatus | ForEach {
If ($_.ProvisioningStatus -eq "Disabled" -or $_.ServicePlan.ServiceName -like "*YAMMER*" -or $_.ServicePlan.ServiceName -like "*VIVAENGAGE_CORE*")
{ $disabledplans += "$($_.ServicePlan.ServiceName)" }

# Remove licenses from user account
$LicenseOptions = New-MsolLicenseOptions -AccountSkuId $AccountSkuId -DisabledPlans $disabledplans
Set-MsolUserLicense -UserPrincipalName $user -LicenseOptions $LicenseOptions 

Get disabled licenses for a user with PowerShell

# Get all disabled licenses for a user
$user = "Bender@planetxpress.net"
(Get-MsolUser -UserPrincipalName $user).licenses.ServiceStatus | Where-Object { $_.ProvisioningStatus -eq 'Disabled' }

# Get disabled licenses named Yammer or Viva
$user = "Bender@planetxpress.net"
(Get-MsolUser -UserPrincipalName $user).licenses.ServiceStatus | Where-Object { ($_.ServicePlan.ServiceName -like '*Yammer*' -or $_.ServicePlan.ServiceName -like '*Viva*') -and ($_.ProvisioningStatus -eq 'Disabled') } 

Enable all license services for a user with PowerShell Set-MsolUserLicense

Use the following PowerShell if you need to re-enable all disabled licenses

$LO = New-MsolLicenseOptions -AccountSkuId $acctSKU
Set-MsolUserLicense -UserPrincipalName $userUPN -LicenseOptions $LO 

Related Posts



No comments made yet. Be the first to submit a comment
Already Registered? Login Here
Saturday, 23 September 2023
You can help support this website by buying me a coffee!
Buy Me A Coffee