I have found a code and edited it to disable sway, planner, yammer and skype for ofiice365 licenses. I want to be able to apply this to all users for that particular license. Currently the code only does it for one user. I also want to be able to make it into a function to get ad users in a OU and then run the script for each user in that OU
$upn = “test@testmail.com”
Get the current licenses (this pulls the top level, like Office 365 Enterprise, Project Online etc.
This will run against all your Office 365 users and only take action on those that have the specified Sku applied. Make sure you replace the value of $TenantName with your own tenant. Also, you may want to make sure this does exactly what you want by filtering down to one user or a few users first. The MSOL cmdlets don’t support -WhatIf, so you’re on your own to verify that your actions are correct.
I’ve done things like this in a function before, if I get a moment today I may see if I can expand on the above in a way that makes sense. Also, I’ve come to expect some errors whenever I do bulk licensing in Office 365, so you may need to add in some code to handle those without stopping the whole process. For more details, see my blog series on Office 365 licensing with PowerShell.
Ahh… I see now. I copied and pasted some of your original code and forgot to update the value for the -UserPrincipalName parameter. I fixed this above - see if it works for you now.
the code runs and I don’t get any errors but I’ve encountered a weird issue. For some users it has disabled the services, but for some it only disables 1/2 services and for some it hasn’t disabled it at all
I have updated the &TenantName variable to the one for my organisation. From running the Get-MsolAccountSku I have checked to make sure “STANDARDWOFFPACK_IW_STUDENT” is the licence applied to user accounts.
i have edited the code so that it only disables Planner = Projectworkmanagement. when I run the code it has disabled this as I wanted it to. but if I add Sway and Yammer it doesn’t disable those services.
Thank you. before I try the above code i want to have a code that enables the services but don’t know where to start on editing the above code. Any help will be much appreciated.
I mean I have a code that disables the planner licence. if in the future I want this feature enabled again for all users - i would like a code that would do this for all users. e.g. SWAY is currently disabled for all users. we are thinking of enabling this for all students. This is a code that I have, but it only does it for one user:
$upn = “user@domain.com”
$licensedetails = (Get-MsolUser -UserPrincipalName $upn ).Licenses
$ldo = @()
$licensedetails.Count;
if ($licensedetails.Count -gt 0){
foreach ($ld in $licensedetails){
if ($ld.AccountSkuId -eq “tenant:STANDARDWOFFPACK_IW_STUDENT”){
foreach ($lds in $ld.ServiceStatus){
if ($lds.ProvisioningStatus -eq “Disabled”){
if ($lds.ServicePlan.ServiceName -ne “SWAY”){
$ldo = $ldo + $lds.ServicePlan.ServiceName.ToString()
}
}
}
}
}
}
$LO = New-MsolLicenseOptions -AccountSkuId “tenant:STANDARDWOFFPACK_IW_STUDENT” -DisabledPlans $ldo
Set-MsolUserLicense -UserPrincipalName $upn -LicenseOptions $LO
I ment removing the wanted one from $Disabled so it will be enabled again. I think that the String is not the ideal for this purpose, because we cannot easily identify where that value is, when the String is something1, something2, something4, something3. So we cannot determ is the value we need to remove st the beginning, middle of at the end, so we cnnot easily remove the comma. So I think that if we create instead a hashtable where we could add values and easily remove the wanted one and after that convert the hashtable to string.
Edit. I removed the old post because it was not working.