Office 365 – User Licensing basics using PowerShell

I’ve been doing quite a bit of work around Office 365 lately, and have been getting a number of question’s around licensing of users.

In this post ill cover the most basic commands needed for managing users. Sometime i’ll hopefully find the time to write a post covering some of the more detailed options available when managing licenses.

Salamander Active Directory
Firstly, I should say that Salamander Active Directory can now handle the Licensing needs for most schools.

It can be used to manage the licenses for existing users as well as new starters and leavers.

Connecting to Office 365
The first step is to connect to Office 365. If your not familar with this, have a look at this post: http://blog.atkinson-it.com/?p=109

List all the License Plans
Licenses are packaged into plans. When you are working in Office 365 online, you’ll see the ‘display’ name for these, but when working in Powershell you need to know their ‘real’ name, or AccountSKU.

You can very quickly get a list of the AccountSKU’s in your Tenancy using:

#Basic command
Get-MsolAccountSku

#More detailed information
Get-MsolAccountSku | Format-Table AccountSkuId, SkuPartNumber, ActiveUnits, ConsumedUnits

Service Plans
Once you’ve established the names of the Plans, it is often useful to look at the service plans inside those. Often it may be that a user doesn’t need to have all the available service plans when configuring licenses.

In my Office 365 setup, i have a number of License plans, including:

SalamanderSoft:ENTERPRISEPACK

In the Office 365 Admin Centre this shows as:

EnterprisePack

In Powershell, you can get a list of these service plans using:

$ServicePlans = Get-MsolAccountSku | Where {$_.AccountSkuId -eq "SalamanderSoft:ENTERPRISEPACK"}
$ServicePlans.ServiceStatus

This will list the available service plans in the Pack selected.

In my tenancy these are:

serviceplan

Seeing the licenses for a single user
Sometimes its useful to view the license status for an exsiting user. This is easily done using the following:

$user = "testUser@salamandersoft.co.uk"
(Get-MSOLUser –UserPrincipalName $user).Licenses[0].ServiceStatus

 

Add a License for a single user
Adding a license with a full pack is very straight forward and can be done with a single command.

Here i am using the variable $user to define the user in question.
You could just add the Full UPN of the user instead.

 

$user = "myuser@mydomain.com"
Set-MsolUserLicense -UserPrincipalName $user -AddLicenses SalamanderSoft:ENTERPRISEPACK 

Adding a License using License Options
Where a user doesn’t need to get the full pack, you can add specific set of plans, by using Licence Options.

In this example, i have used the license options parameter to add the license, with some of the options disabled.

#Set License Options (to disable various plans)
$MyLicenseOptions = New-MsolLicenseOptions -AccountSkuId SalamanderSoft:ENTERPRISEPACK -DisabledPlans OFFICESUBSCRIPTION, RMS_S_ENTERPRISE,MCOSTANDARD

#Set Licenses using the options above
Set-MsolUserLicense -UserPrincipalName $user -AddLicenses SalamanderSoft:ENTERPRISEPACK -LicenseOptions $MyLicenseOptions

This will result in the Office 365 Admin page looking like this:

EnterprisePack

Removing a License for a single user
We can also remove the license for a single user with a single command.

Set-MsolUserLicense -UserPrincipalName $user -RemoveLicenses SalamanderSoft:ENTERPRISEPACK

Yammer? What’s it all about?

Since Yammer was added to our office 365 package, we’ve been using it internally at work and I’ve been thinking about how our customers might be able to utilise it in the future.

What is it?
Yammer is being billed as the ‘Enterprise Social Network’. It’s use has a familiar feel, and students and staff alike will have no difficulty in picking it up. Much like Facebook, there is a newsfeed, but this is much more than that. Yammer is also great for sharing files between co-workers, and having discussions in groups.

So, how much will it cost me?
The good news here is that if you are an Education institution using Office 365, the answer will be nothing.

From April 1st 2014, Microsoft are adding Yammer Enterprise to all of the Office 365 Education plans (A2,A3 and A4)

How might we use it?
Initially, you might think that this is just a gimmick, another toy for people to use with very little useful points. I know I did.

However, after spending some time using it, and thinking about it, I’m confident that there will be a future for Yammer in Education.

In a similar way to Facebook, Yammer supports groups, which allows people to communicate and collaborate on specific topics, or even class by class.

Imagine if each class had a Yammer group where they could share ideas and chat about work, from anywhere.

If your using SharePoint, you can also embed the feed from a group in the class site, and collaborate directly through that, in effect adding to your SharePoint environment.

There are also plans to integrate Office Web Apps with Yammer too, so your staff and pupils could collaborate directly on documents directly from the document itself.

Use it from anywhere
As yammer is part of Office 365, there are many apps available for almost every device and platform, allowing users to collaborate from wherever they are, using whatever they already have. No extra hardware required.

In short, there is a lot more to Yammer than meets the eye, and its well worth investigating what it can do for you.

Connecting to Office 365 Using PowerShell

More and more the focus is on Office 365, and a lot of the niftier management can/should be done with PowerShell.

Recently, i have been working more and more with Office 365, and connecting to it can be a bit of a pain.

Here, I will demonstrate a couple of ways that you can connect to Office 365 easily, as something you will be doing more and more.

I will also demonstrate a way that you can save the password securely in a separate file, so you don’t have to keep entering it, or have it available in plain text.

Connecting to Office 365 – Prerequisites
Firstly, in order to connect to Office 365 you must have the Windows Azure AD Module for PowerShell installed.

You can find this here:
http://msdn.microsoft.com/en-us/library/windowsazure/jj151815.aspx#bkmk_installmodule

Connecting to Office 365
A quick Google will give you then commands you need to connect to Office 365 from your new Shell, but i tend to use this set of commands.

#Connect to Office 365, Prompting for Credentials
Import-Module MSOnline
$O365Cred = Get-Credential
$O365Session = New-PSSession –ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $O365Cred -Authentication Basic -AllowRedirection
Import-PSSession $O365Session
Connect-MsolService –Credential $O365Cred

In its most basic form, this will Import the MSOnline powershell module (the one you have just installed) and connect to the Office 365 Service, prompting for your username and password.

This works well, but if you use it often, it can be a pain to keep giving your credentials.

Saving the Password Securely
You can simply add the password to the script, but this will be in plain text, which is not ideal.

To save the password in a more secure fashion, I use the PowerShell script below:

#Set location of TXT file to store the password
$secureFilePath = "D:\365SecureString.txt"

#Enter the password when prompted
#It will be stored in a secure string
Read-Host -Prompt "Enter password to be encrypted in secure string text file" -AsSecureString |
ConvertFrom-SecureString |
#Location of the file to secure the string inside
Out-File $secureFilePath

This will prompt you for a password and save it in a more secure fashion to the file you specify at the top.

Once this file is saved, it can be accessed by any other PowerShell script, simply by reading the file

$pass = GetContent $secureFilePath | ConvertTo-SecureString

Want more on Passwords?
Check out Todd Klindt’s post on using Passwords with PowerShell HERE

Disclaimer on Secure Passwords
Unfortunately, I have to say that there are a couple of ways that this password can be read later on, but only by someone who has the knowledge and access to your file. It will certainly stop someone stumbling upon it.

Putting it together
Now that i have my password stored, you can add this location to the script to connect, and with a couple of tweaks have as script that will connect to Office 365 without any prompting.

Here, I’ve added it as a function. This was, i could save this into my PowerShell Profile so i could access it easily every time I needed it.

Function Connect365 {
    #Location of Password in TXT file
    $secureFilePath = "D:\365SecureString.txt"
    $userName = "myuser@mydomain.onmicrosoft.com"
    $pass = Get-Content $secureFilePath | ConvertTo-SecureString                                                           
    $O365Cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $userName,$pass     

    #Function to connect to MSOL using the secure string
    Import-Module MSOnline

    #$O365Cred = Get-Credential
    $O365Session = New-PSSession –ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $O365Cred -Authentication Basic -AllowRedirection
    Import-PSSession $O365Session
    Connect-MsolService –Credential $O365Cred
}

Connect365

I’ll cover the use of functions a little more in another blog.