15 49.0138 8.38624 1 0 4000 1 https://vladtalkstech.com 300 1
theme-sticky-logo-alt

Disable Yammer Licenses in Office 365 with PowerShell

9 Comments

On February 2nd 2016, Microsoft did a surprise blog post to Office 365 admins to announce that starting the same day, Microsoft will automatically activate Yammer on every new and existing tenant. Compared to most Office 365 services like Exchange, SharePoint and Skype for Business, enterprises didn’t always want to add a social network for their users. Furthermore, since Yammer is currently only hosted in the United States, some enterprises don’t want their data hosted in the US for multiple reasons.

That is why I made this PowerShell script that will disable Yammer licenses for all your users so you don’t have to do it by hand. This script will loop trough all your licensed users, and disable Yammer. The Script supports different SKU for each user, so if your users will be assigned the same license, but without Yammer inside. Make sure you are connected to Office 365 before running the script as I didn’t include that part! If you don’t know how to connect to Office 365, check out the tutorial on the PowerShell Portal. You might also be interested in learning more about PowerShell for Office 365 to better understand the script, and be able to make your own. Check out my Pluralsight course on PowerShell for Office 365 to become a pro!

PowerShell For Office 365

I also have added a cool output so you can see what the script is up to. Here is a screenshot of what it looks like when it runs!

Disable Yammer Licenses in Office 365 with PowerShell

You can find the script below, or you can download it from the TechNet Gallery here: https://gallery.technet.microsoft.com/Disable-Yammer-in-Office-432f584d 

NOTE: If you have an EDU tenant, you will need to change “YAMMER_ENTERPRISE” to “YAMMER_EDU” . Thanks to Maurits Knoppert for the tip!

#MAKE SURE YOU ARE CONNECTED TO OFFICE 365 BEFORE RUNNING THIS SCRIPT
#If you don't know how check out: http://powershell.office.com/script-samples/connect-to-Azure-AD 
#If you want to learn more about PowerShell for Office 365 and make your own awesome scripts, check out my course on Pluralsight
#Find it at: http://spvlad.com/1VXll7f 

#Get All Licensed Users
$users = Get-MsolUser | Where-Object {$_.isLicensed -eq $true}

foreach ($user in $users)
{
	Write-Host "Checking " $user.UserPrincipalName -foregroundcolor "Cyan"
	$CurrentSku = $user.Licenses.Accountskuid
			#If more than one SKU, Have to check them all!
			if ($currentSku.count -gt 1)
			{
				Write-Host $user.UserPrincipalName "Has Multiple SKU Assigned. Checking all of them" -foregroundcolor "White"
				for($i = 0; $i -lt $currentSku.count; $i++)
				{
					#Loop trough Each SKU to see if one of their services has the word Yammer inside
					if($user.Licenses[$i].ServiceStatus.ServicePlan.ServiceName -like "*Yammer*" )
						{
						Write-host $user.Licenses[$i].AccountSkuid "has Yammer. Will  Disable" -foregroundcolor "Yellow"
						$NewSkU = New-MsolLicenseOptions -AccountSkuId $user.Licenses[$i].AccountSkuid -DisabledPlans YAMMER_ENTERPRISE
						Set-MsolUserLicense -UserPrincipalName $user.UserPrincipalName -LicenseOptions $NewSkU
						Write-Host "Yammer disabled for " $user.UserPrincipalName " On SKU " $user.Licenses[$i].AccountSkuid -foregroundcolor "Green"
						}
					else
						{
						Write-host $user.Licenses[$i].AccountSkuid " doesn't have Yammer. Skip" -foregroundcolor "Magenta"
						}
				}
			}
			else
			{
				$NewSkU = New-MsolLicenseOptions -AccountSkuId $CurrentSku -DisabledPlans YAMMER_ENTERPRISE
				Set-MsolUserLicense -UserPrincipalName $user.UserPrincipalName -LicenseOptions $NewSkU
				Write-Host "Yammer disabled for " $user.UserPrincipalName -foregroundcolor "Green"
			}
}

 

Follow me on Social Media and Share this article with your friends!

Leave a comment and don’t forget to like the Absolute SharePoint Blog Page   on Facebook and to follow me on Twitter here  for the latest news and technical articles on SharePoint.  I am also a Pluralsight author, and you can view all the courses I created on my author page.
Previous Post
Win a free Pass to SharePoint Fest DC 2016
Next Post
Microsoft is retiring SharePoint MCSD developer exams

9 Comments

  • February 17, 2016 at 11:29 am
    Barney

    Hi Vlad,

    I can see this will be useful for some people but I’m worried that it might, in some cases, have some unintended consequences: The “-DisabledPlans” parameter of the “New-MsolLicenseOptions” cmdlet needs to contain all disabled plans – if you put Yammer in there alone, it’ll set all other plans to their defaults of enabled. My concern is that customers may have disabled other plans and by running this script they will undo those changes.

    A better approach would be to iterate over each user’s current licensing options and build a list of currently disabled plans, (if any), then add Yammer to that list before setting their license options. The PowerShell example in the documentation does this: https://support.office.com/en-us/article/Manage-Yammer-user-licenses-in-Office-365-34a67e3a-3fd8-4e54-bffb-dd5ad0e48590?ui=en-US&rs=en-US&ad=US

    Cheers,
    Barney.

    Reply
    • February 17, 2016 at 2:45 pm

      You are right Barney, I will update to put a note about it!

      Reply
  • May 27, 2016 at 3:55 pm
    Zacharry

    Just an FYI to anyone looking for the note mentioned above, you separate desired plans with commas:

    -DisabledPlans YAMMER_ENTERPRISE,SWAY

    Reply
    • August 23, 2016 at 11:05 am
      RoySton

      FYI: -DisabledPlans YAMMER_ENTERPRISE,SWAY is wrong. Put a space after the comma or it will reject the change.

      Reply
  • September 1, 2016 at 4:25 pm
    Aniket

    I am trying to run this script to remove Yammer Licenses in bulk. However get a message saying Warning : Please mention the Max or ALL parameter. Can you help ?

    Reply
  • September 21, 2016 at 1:00 pm
    Patrick

    How would I do the opposite and turn on Yammer for everybody?

    Thanks,
    Patrick

    Reply
  • December 28, 2016 at 9:46 am
    Vinsoft

    Hi. When the script run I receive the following info:
    PS C:\> $users = Get-MsolUser | Where-Object {$_.isLicensed -eq $true}
    More results are available. Please specify one of the All or MaxResults parameters.
    What’s the problem?
    Please, I don’t know the PowerShell command, can you write me whatI have to do?
    Thanks

    Reply
    • June 28, 2017 at 9:56 am

      $users = Get-MsolUser -Limit All | Where-Object {$_.isLicensed -eq $true}

      Reply

Leave a Reply