Thursday, 9 May 2013

Use PowerShell to assign specific service plan licenses to Office 365 users

You can use PowerShell to create users in Office 365 and assign licenses to them.
In order to do it you will first need to see what your Account SKU IDs are by running the following command:

Get-MsolAccountSku







This will give you a list of your available SKUs in the following format:

mydomain:SKU (Example: mydomain:ENTERPRISEPACK)

Now you can use the retrieved "AccountSkuID" to assign licenses to users. Below is an example of creating a new user and assigning E3 (ENTERPRISEPACK) license:

New-MsolUser -UserPrincipalName "amin.tavakoli@mydomain.onmicrosoft.com" -DisplayName "Amin Test1" -FirstName "Amin" -LastName "Test1" -UsageLocation "GB" -LicenseAssignment "mydomain:ENTERPRISEPACK"



You may want to assign specific licenses within a SKU rather than assigning the whole E3 license. In that case you need to create your own license assignment option. To do that we first need to see what the service plan IDs are for each individual service within the E3 SKU. 

Run the following commands to get a list of service plan IDs:

$s = Get-MsolAccountSku | Where {$_.SkuPartNumber -eq "ENTERPRISEPACK"}
$s.ServiceStatus










As you can see, the following are the individual service plans in E3 pack:
RMS_S_ENTERPRISE                 (Windows Azure Active Directory Rights - this is new in Wave 15)
OFFICESUBSCRIPTION              (Office Professional Plus)
MCOSTANDARD                         (Lync Online)
SHAREPOINTWAC                      (Office Web Apps)  
SHAREPOINTENTERPRISE          (SharePoint Online)
EXCHANGE_S_ENTERPRISE        (Exchange Online)

Now we create our own custom plan to assign an individual service plan license to a user. In this example we are assigning SharePoint Online license:

$MyLicenseAssignmentOption = New-MsolLicenseOptions -AccountSkuId "mydomain:ENTERPRISEPACK" -DisabledPlans RMS_S_ENTERPRISE, OFFICESUBSCRIPTION, MCOSTANDARD, SHAREPOINTWAC, EXCHANGE_S_ENTERPRISE

As you can see we still set the AccountSkuId to "mydomain:ENTERPRISEPACK", however using the DisabledPlans switch we are disabling all the other service plans, leaving SharePoint Online only.

Now that we have created our own license assignment option, we can re-run the New-MsolUser command and add our own license option to it:

New-MsolUser -UserPrincipalName "amin.tavakoli@mydomain.onmicrosoft.com" -DisplayName "Amin Test1" -FirstName "Amin" -LastName "Test1" -UsageLocation "GB" -LicenseAssignment "mydomain:ENTERPRISEPACK" -LicenseOptions $MyLicenseAssignmentOption

On the portal we can check the license assignment status of the new user that we just created and we can see only SharePoint Online license is assigned to the user:

 


4 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Great explanation! It's helpful to someone trying to figure this out.
    If you want to change an already licensed user's license options, to add Exchange as a license options as well as retaining their existing Sharepoint, you can do something like this:

    $MyOtherLicenseAssignmentOption = New-MsolLicenseOptions -AccountSkuId "mydomain:ENTERPRISEPACK" -DisabledPlans RMS_S_ENTERPRISE, OFFICESUBSCRIPTION, MCOSTANDARD, SHAREPOINTWAC

    get-msoluser -UserPrincipalName amin.tavakoli@mydomain.onmicrosoft.com | Set-MsolUserLicense -LicenseOptions $MyOtherLicenseAssignmentOption

    ReplyDelete
  4. Great Amin jan
    thank you very much
    ref.http://technet.microsoft.com/en-us/library/dn530773.aspx

    ReplyDelete