Problem disabling Office 365 service plans for all licensed users
I am trying to disable several of the service plans in Office 365 for all licensed users. I am able to create the object reference to hold the services that I are going to disable using:
$O365Licences = New-MsolLicenseOptions AccountSkuId contoso:ENTERPRISEPACK_faculty -DisabledPlans MSCOSTNADARD, SHAREPOINTWAC_EDU, SHAREPOINTENTERPRISE_EDU
When I run
Get-MsolUser -All | Set-MsolUserLicense -LicenseOptions $O365Licences
I get the following error messages.
Set-MsolUserLicense : Unable to assign this license because the license options
are invalid.
At line:1 char:40
+ Get-MsolUser -All | Set-MsolUserLicense <<<< -LicenseOptions $O365Licences
+ CategoryInfo : OperationStopped: (:) [Set-MsolUserLicense], Mic
rosoftOnlineException
+ FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.Inval
idUserLicenseOptionException,Microsoft.Online.Administration.Automation.Se
tUserLicense
Set-MsolUserLicense : Unable to assign this license because the license options
are invalid.
At line:1 char:40
+ Get-MsolUser -All | Set-MsolUserLicense <<<< -LicenseOptions $O365Licences
+ CategoryInfo : OperationStopped: (:) [Set-MsolUserLicense], Mic
rosoftOnlineException
+ FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.Inval
idUserLicenseOptionException,Microsoft.Online.Administration.Automation.Se
tUserLicense
Set-MsolUserLicense : Unable to assign this license because the license options
are invalid.
At line:1 char:40
+ Get-MsolUser -All | Set-MsolUserLicense <<<< -LicenseOptions $O365Licences
+ CategoryInfo : OperationStopped: (:) [Set-MsolUserLicense], Mic
rosoftOnlineException
+ FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.Inval
idUserLicenseOptionException,Microsoft.Online.Administration.Automation.Se
tUserLicense
Set-MsolUserLicense : Unable to assign this license because the license options
are invalid.
At line:1 char:40
+ Get-MsolUser -All | Set-MsolUserLicense <<<< -LicenseOptions $O365Licences
+ CategoryInfo : OperationStopped: (:) [Set-MsolUserLicense], Mic
rosoftOnlineException
+ FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.Inval
idUserLicenseOptionException,Microsoft.Online.Administration.Automation.Se
tUserLicense
Set-MsolUserLicense : Unable to assign this license because the license options
are invalid.
At line:1 char:40
+ Get-MsolUser -All | Set-MsolUserLicense <<<< -LicenseOptions $O365Licences
+ CategoryInfo : OperationStopped: (:) [Set-MsolUserLicense], Mic
rosoftOnlineException
+ FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.Inval
idUserLicenseOptionException,Microsoft.Online.Administration.Automation.Se
tUserLicense
Set-MsolUserLicense : Unable to assign this license because the license options
are invalid.
At line:1 char:40
+ Get-MsolUser -All | Set-MsolUserLicense <<<< -LicenseOptions $O365Licences
+ CategoryInfo : OperationStopped: (:) [Set-MsolUserLicense], Mic
rosoftOnlineException
+ FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.Inval
idUserLicenseOptionException,Microsoft.Online.Administration.Automation.Se
tUserLicense
September 8th, 2015 8:23am
Set-MsolUserLicense -UserPrincipalName testUser -RemoveLicenses "contoso:ENTERPRISEPACK"
Get-MsolUser -All | Set-MsolUserLicense -RemoveLicenses contoso:ENTERPRISEPACK_faculty
If you want to remove all licenses from the user, '-RemoveLicenses'
-
Edited by
vaadadmin2010
18 hours 28 minutes ago
September 8th, 2015 8:35am
I want to disable several of the service plans\licenses. As long as the users have a valid e-mail account they are able to create an Office 365 account.
We do not want users to access to Office Online and SharePoint. We would prefer not to have to run a PS script on all the user accounts several times a day.
September 8th, 2015 9:06am
To change certain users and specific licenses. Try this to disable specific items. This reads the username and the applications from a sql database, but should give you the general idea.
if ($reader["RMS_S_ENTERPRISE"] -notlike "ENABLED") { $DisabledOptions += "RMS_S_ENTERPRISE" }
if ($reader["OFFICESUBSCRIPTION"] -notlike "ENABLED") { $DisabledOptions += "OFFICESUBSCRIPTION" }
if ($reader["MCOSTANDARD"] -notlike "ENABLED") { $DisabledOptions += "MCOSTANDARD" }
if ($reader["SHAREPOINTWAC"] -notlike "ENABLED") { $DisabledOptions += "SHAREPOINTWAC" }
if ($reader["SHAREPOINTENTERPRISE"] -notlike "ENABLED") { $DisabledOptions += "SHAREPOINTENTERPRISE" }
if ($reader["EXCHANGE_S_ENTERPRISE"] -notlike "ENABLED") { $DisabledOptions += "EXCHANGE_S_ENTERPRISE" }
Try
{
Set-MsolUser -UserPrincipalName $reader["UserName"] -UsageLocation "US"
$applyNewLicense = New-MsolLicenseOptions -AccountSkuId "contoso:ENTERPRISEPACK" -DisabledPlans $DisabledOptions
Set-MsolUserLicense -UserPrincipalName $reader["UserName"] -AddLicenses contoso:ENTERPRISEPACK -LicenseOptions $applyNewLicense -ErrorAction Stop
September 8th, 2015 9:33am
I want to disable several of the service plans\licenses. As long as the users have a valid e-mail account they are able to create an Office 365 account.
We do not want users to access to Office Online and SharePoint. We would prefer not to have to run a PS script on all the user accounts several times a day.
Create an array of disabled products.
$disabledplans = "SHAREPOINTWAC_EDU","SHAREPOINTENTERPRISE_EDU"
$options = New-MsolLicenseOptions -AccountSkuId ... -DisabledPlans $disabledplans
Set-MsolUserLicense -UserPrincipalName $upn -LicenseOptions $options
September 8th, 2015 9:47am
When I try to run Set-MsolUserLicense -UserPrincipalName $upn -LicenseOptions $options I get
Set-MsolUserLicense : Cannot bind argument to parameter 'UserPrincipalName' bec
ause it is null.
At line:1 char:39
+ Set-MsolUserLicense -UserPrincipalName <<<< $upn -LicenseOptions $options
+ CategoryInfo : InvalidData: (:) [Set-MsolUserLicense], Paramete
rBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
icrosoft.Online.Administration.Automation.SetUserLicense
September 8th, 2015 9:58am
When I try to run Set-MsolUserLicense -UserPrincipalName $upn -LicenseOptions $options I get
Set-MsolUserLicense : Cannot bind argument to parameter 'UserPrincipalName' bec
ause it is null.
At line:1 char:39
+ Set-MsolUserLicense -UserPrincipalName <<<< $upn -LicenseOptions $options
+ CategoryInfo : InvalidData: (:) [Set-MsolUserLicense], Paramete
rBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
icrosoft.Online.Administration.Automation.SetUserLicense
assign $upn to one of your users.
September 8th, 2015 10:06am
Isn't there any way to disable a service for all users?
According to TID - https://support.office.com/en-us/article/Disable-Office-365-Service-Plans-with-Windows-PowerShell-a1754aa5-5055-47a4-82e1-2291849cb476
You just need to run the following commands.
$O365Licences = New-MsolLicenseOptions AccountSkuId contoso:ENTERPRISEPACK -DisabledPlans MSCOSTNADARD, SHAREPOINTWAC
Get-MsolUser -All | Set-MsolUserLicense -LicenseOptions $O365Licences
September 8th, 2015 10:10am
Isn't there any way to disable a service for all users?
According to TID - https://support.office.com/en-us/article/Disable-Office-365-Service-Plans-with-Windows-PowerShell-a1754aa5-5055-47a4-82e1-2291849cb476
You just need to run the following commands.
$O365Licences = New-MsolLicenseOptions AccountSkuId contoso:ENTERPRISEPACK -DisabledPlans MSCOSTNADARD, SHAREPOINTWAC
Get-MsolUser -All | Set-MsolUserLicense -LicenseOptions $O365Licences
You could certainly try that..I'm not going to:-)
September 8th, 2015 10:15am
When I run the command Get-MsolUser -All | Set-MsolUserLicense -LicenseOptions $O365Licences in our test tenant, I get the following error messages:
Set-MsolUserLicense : Unable to assign this license because the license options
are invalid.
At line:1 char:40
+ Get-MsolUser -All | Set-MsolUserLicense <<<< -LicenseOptions $O365Licences
+ CategoryInfo : OperationStopped: (:) [Set-MsolUserLicense], Mic
rosoftOnlineException
+ FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.Inval
idUserLicenseOptionException,Microsoft.Online.Administration.Automation.Se
tUserLicense
September 8th, 2015 10:21am
Hope the account SKU ID you used is correct!
and what happens if you change the -DisabledPlans as array objects for example
$O365Licences = New-MsolLicenseOptions AccountSkuId contoso:ENTERPRISEPACK -DisabledPlans @("MSCOSTNADARD", "SHAREPOINTWAC")
Get-MsolUser -All | Set-MsolUserLicense -LicenseOptions $O365Licences
If the above fails then the issur may be due to two different subscription - Which results in two Sku ID
September 8th, 2015 10:22am
Hope the account SKU ID you used is correct!
and what happens if you change the -DisabledPlans as array objects for example
$O365Licences = New-MsolLicenseOptions AccountSkuId contoso:ENTERPRISEPACK -DisabledPlans @("MSCOSTNADARD", "SHAREPOINTWAC")
Get-MsolUser -All | Set-MsolUserLicense -LicenseOptions $O365Licences
If the above fails then the issur may be due to two different subscription - Which results in two Sku ID
September 8th, 2015 10:29am
The key is the array. I've run into issues before with the comma separated list. That and MS adding/removing/linking products without notice.
September 8th, 2015 10:36am
I get the same error message. The account SKU ID that I using is correct.
September 8th, 2015 10:55am
I get the same error message. The account SKU ID that I using is correct.
try it against one user first.
September 8th, 2015 11:07am
I am able to disable the service plan\license for an individual user. When I try to disable a service plan for all users, I get the error messages however the service plans\licenses are disabled when I check individual user accounts.
September 8th, 2015 11:20am
Set-MsolUserLicense -UserPrincipalName testUser -RemoveLicenses "contoso:ENTERPRISEPACK"
Get-MsolUser -All | Set-MsolUserLicense -RemoveLicenses contoso:ENTERPRISEPACK_faculty
If you want to remove all licenses from the user, '-RemoveLicenses'
-
Edited by
vaadadmin2010
Tuesday, September 08, 2015 12:40 PM
September 8th, 2015 12:34pm
I am able to disable the service plan\license for an individual user. When I try to disable a service plan for all users, I get the error messages however the service plans\licenses are disabled when I check individual user accounts.
This would suggest the command is working against licensed users and you may be seeing the error on the unlicensed. Have you verified all users are licensed?
Get-MsolUser -all |select -first 50
September 8th, 2015 12:51pm
Of the six accounts in test tenant, I can see that half them are licensed. The other half are showing up as false under the isLicensed column.
September 8th, 2015 1:15pm
Of the six accounts in test tenant, I can see that half them are licensed. The other half are showing up as false under the isLicensed column.
OK that's probably why you're seeing the error then.
September 8th, 2015 1:28pm
I went in and assigned licenses to the accounts that did not have a license. How long does it take for that info to be replicated\synced with the rest of the tenant?
September 8th, 2015 1:36pm
I tried running the following commands again.
$O365Licences = New-MsolLicenseOptions AccountSkuId xxxx:ENTERPRISEPACK -DisabledPlans MSCOSTNADARD, SHAREPOINTWAC
Get-MsolUser -All | Set-MsolUserLicense -LicenseOptions $O365Licences
I get the following error messages:
Set-MsolUserLicense : Unable to assign this license because the license options
are invalid.
At line:1 char:40
+ Get-MsolUser -All | Set-MsolUserLicense <<<< -LicenseOptions $O365Licences
+ CategoryInfo : OperationStopped: (:) [Set-MsolUserLicense], Mic
rosoftOnlineException
+ FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.Inval
idUserLicenseOptionException,Microsoft.Online.Administration.Automation.Se
tUserLicense
September 8th, 2015 2:06pm