Before you could assign a license using PowerShell, you need to connect to Microsoft Azure AD.
Once you are connected, let's first see what sort of license your organization has purchased or available for assigning to users.
Once you are connected, let's first see what sort of license your organization has purchased or available for assigning to users.
$AccountSku = Get-MsolAccountSku
Now you can return the "$AccountSku" to see what are license type available.
AccountSkuId ActiveUnits WarningUnits ConsumedUnits
------------ ----------- ------------ -------------
<tenant>:ENTERPRISEPACKWITHOUTPROPLUS 20000 7000 10000
<tenant>:ENTERPRISEPACK 25000 14000 13000
If your organization has only one type of license, then you will only see one entry.
Now let's find out what product are available.
$AccountSku[0].ServiceStatus
$AccountSku[1].ServiceStatus
We can run the below command to return the product type.
$AccountSku[0].ServiceStatus
ServicePlan ProvisioningStatus
----------- ------------------
SWAY Success
YAMMER_ENTERPRISE Success
SHAREPOINTWAC Success
SHAREPOINTENTERPRISE Success
RMS_S_ENTERPRISE Success
MCOSTANDARD Success
EXCHANGE_S_ENTERPRISE Success
$AccountSku[1].ServiceStatus
ServicePlan ProvisioningStatus
----------- ------------------
PROJECTWORKMANAGEMENT Success
SWAY Success
YAMMER_ENTERPRISE Success
RMS_S_ENTERPRISE Success
OFFICESUBSCRIPTION Success
MCOSTANDARD Success
SHAREPOINTWAC Success
SHAREPOINTENTERPRISE Success
EXCHANGE_S_ENTERPRISE Success
we can see Provisioningstatus is set to Success, so it means, that those products could be assigned to a user.
Assigning License to a User
Now, lets assign a license to User Account.
Before we can assign the license, we will have to setup the usage location, below are the PowerShell command which can be run to set the Usage Location.
Usage location is where you want the user mailbox to be setup in office365, please make sure to set accordingly.
$UPN="Sunil@<tenant>.onmicrosoft.com"
Set-MsolUser -UserPrincipalName $UPN -UsageLocation US
Set-MsolUserLicense -UserPrincipalName $upn -AddLicenses <tenant>:ENTERPRISEPACKWITHOUTPROPLUS
Now, if you want to assign, all the product available in the License, then we are all set with the License assignment by running the above command, but if we want to disable a few of the products, then we have to run the below cmd as well.
Lets say we just want to enable only the Exchange and Skype for Business for User.
# Disabling office online, Sharepoint, Sway and Yammer
$LP = New-MsolLicenseOptions -AccountSkuId <tenant>:ENTERPRISEPACKWITHOUTPROPLUS `
-DisabledPlans SWAY, YAMMER_ENTERPRISE, SHAREPOINTWAC, SHAREPOINTENTERPRISE
Set-MsolUserLicense -UserPrincipalName $upn -LicenseOptions $LP
After running the above command we can verify the license assignment, by running the below cmd.
(Get-MsolUser -UserPrincipalName "Sunil@<tenant>.onmicrosoft.com").Licenses.ServiceStatus
Comments
Post a Comment