How to check your user licenses in Office 365

I recently got asked by one of my clients to check what users were on what plan in their Microsoft Office 365 account. You can imagine my surprise when Microsoft billing told me the only way to do this was to go down each user in the administrative portal, click on them and check the licensing page to see what license is assigned. I asked if there was a way to do this with Powershell and I got sent off to technical support. They found nothing that would do this in their quick technical answers and they would have to get back to me.

After a bit of research on my own, I ended up creating my own script to get the information. Here’s that script:

—————————————————————————————————

# Script to retrieve a licensing report from Office 365 and output it to CSV

# DISCLAIMER

# The sample scripts are not supported under any Microsoft standard support program or service.

# The sample scripts are provided AS IS without warranty of any kind.

# The entire risk arising out of the use or performance of the sample scripts and documentation remains with you.

# Created by Ted Giesler http://blog.cypgrp.com

Function Get-FileName($initialDirectory)

{

     [System.Reflection.Assembly]::LoadWithPartialName(“System.windows.forms”) | Out-Null

     $OpenFileDialog = New-Object System.Windows.Forms.SaveFileDialog

     $OpenFileDialog.initialDirectory = $initialDirectory

     $OpenFileDialog.filter = “All files (*.*)| *.*”

     $OpenFileDialog.ShowDialog() | Out-Null

     $OpenFileDialog.filename

     If ($Show -eq “OK”)

        {

        Return $objForm.FileName

        }

    Else

        {

        Write-Error “Operation cancelled by user.”

        Exit

        }

} #end function Get-FileName

# *** Entry Point to Script ***

# load the MSOnline PowerShell Module

# verify that the MSOnline module is installed and import into current powershell session

If (!([System.IO.File]::Exists((“{0}\modules\msonline\Microsoft.Online.Administration.Automation.PSModule.dll” -f $pshome))))

{

    Write-Host “The Microsoft Online Services Module for PowerShell is not installed. The Script cannot continue.”

    write-host “Please download and install the Microsoft Online Services Module.”

    Exit

}

$getModuleResults = Get-Module

If (!$getModuleResults)

{

    Import-Module MSOnline -ErrorAction SilentlyContinue

}

Else

{

    $getModuleResults | ForEach-Object

        {

            If (!($_.Name -eq “MSOnline”))

        {

        Import-Module MSOnline -ErrorAction SilentlyContinue

        }

        }

}

# Connect to Microsoft Online Service

Connect-MsolService -Credential $cred -errorAction silentlyContinue -errorvariable $er

$users = Get-MsolUser -all

# Setup the output file

$defaultfolder = $Env:UserProfile + “\documents”

$outfile = GEt-Filename ($defaultfolder)

$header = “userPrincipaName,usageLocation,isLicensed,accountSKUid,servicePlan1,provisioningStatus1,servicePlan2,provisioningStatus2,servicePlan3,provisioningStatus3,servicePlan4,provisioningStatus4,servicePlan5,provisioningStatus5”

Out-File -FilePath $outfile -InputObject $header

# Write-Host $header

foreach($usr in $users)

{

    $lineOut=$usr.UserPrincipalName + “,” + $usr.usageLocation + “,” + $usr.isLicensed + “,”

    foreach($lic in $usr.Licenses)

    {

        $lineOut = $lineOut + $lic.AccountSkuID

        foreach($s in $lic.ServiceStatus)

        {

            $lineout = $lineout + $s.ServicePlan.ServiceName + “,” + $s.ProvisioningStatus +”,”

        }

    }

    Out-File -FilePath $outfile -Append -NoClobber -InputObject $lineOut

    # Write-Host $lineOut

    $lineOut = $null

}

Write-Host -ForeGroundColor BLue “Please review your output file at ” $outFile

————————————————————————————————————————–

This script will create a comma separated file showing each user and each license category that user has a license. Unfortuantely, this does not match nicely to the Office 365 plans. You will have to add the specific licenses together to try and match your Office 365 Plan licenses.

Hopefully this will help others looking for the same type of answers.

How are you most likely to get attacked by Malware?

Recently the Microsoft Trustworthy Computing group released their Microsoft Security Intelligence Report covering the first half of 2012. It is interesting to look at where most malware comes from and what has been the most vulnerable software.

The most prevalent method of malware distribution according to Microsoft had been what they call “unsecure distribution chains.” Fallowing in this category are websites that distribute “free software”, both legal and not legal. Some of the popular software names listed by Microsoft as containing malware include:

  • keygen.exe
  • mini-KMS_Activator_v1.1_Office.2010.VL.ENG.exe
  • AutoCAD-2008-keygen.exe
  • SonyVegasPro Patch.exe
  • Nero Multimedia Suite 10 – Keygen.exe
  • Adobe.Photoshop.CS5.Extended.v12.0.Keymaker-EMBRACE.exe
  • Call.of.Duty.4.Modern.Warfare.Full-Rip.Skullptura.7z
  • Guitar Pro v6.0.7+Soundbanks+Keygen(Registered) [ kk ].rar

They also listed a number of movie named files that contained Malware, including:

  •  The Avengers 2012 720p BDRip QEBS7 AAC20 MP4-FASM.avi
  • Prometheus 2012 DVDRip.avi
  • Wrath of the Titans 2012 DVDRip aXXo.avi
  • Battleship 2012 DVDRip.avi
  • What to Expect When You’re Expecting 2012.BRRip.XviD-KAZAN.avi
  • The Hunger Games 2012 TRUE FRENCH DVDRIP XViD FiCTiON L S79.avi
  • Sherlock.Holmes.2.A.Game.of.Shadows.2012.DVDRip.XviD-26K-0123.avi
  • The Five-Year Engagement 2012 HDRip XviD-HOPE.avi
  • Project X 2012 TRUE FRENCH DVDRIP XViD FiCTiON L S79.avi
  • Amazing SpiderMan 2012 DVDRiP XviD.avi

When looking at what got attacked by malware, the report notes that of the 3 categories, core operating systems, browsers and applications, most malware attacked applications and least attacked were core operating systems, In the application category, Java and Java Script were by far the most attacked, followed by Adobe readers and Adobe flash.

What was even more interesting is that when looking at the implementation of updates of these four applications, over 50% of users were missing the latest updates. In the case of Java, over 90% of users did not have the latest updates installed.

Looking at infections by operating system, Windows XP had the highest percentage of infections at 9.5% of estimated installed computers while Windows 7 SP1 64-bit had the lowest at 3.1%.

So what should a user learn from this report?

  1. Be careful what you download. You may get more than you asked for.
  2. Install your updates. Not just Microsoft ones but Java and Adobe are key.
  3. Run a current operating system. The newer the OS, the less likely you are to get infected. Remember, support for Windows XP ends April, 2014.