Monday, February 15, 2016

Disable Yammer Licenses in Office 365 with PowerShell

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.

Disable Yammer

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: http://ift.tt/1ObQLlF

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://ift.tt/20VYuRv 
#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"
                        }
}

 

The post Disable Yammer Licenses in Office 365 with PowerShell appeared first on Absolute SharePoint Blog by Vlad Catrinescu.


by Vlad Catrinescu via Absolute SharePoint Blog by Vlad Catrinescu

No comments:

Post a Comment