Forum Discussion

Carlos Gomez's avatar
Carlos Gomez
Brass Contributor
Mar 23, 2017
Solved

Office 365 license consumption alert

Hi,

 

Does Microsoft provides any alerting on the case that availabe licenses to assign are\near to be 0?

 

I already see that several blogs provide details for creating your own alerting\report for license consumption using powershell, but I'm interested to confirm if Microsoft has something out of the box.

 

Regards.

  • In terms of alerts, no. A quick glance at the Admin portal or the Reports can give you this info. If you need it automated it really takes few lines of PowerShell code to check for available licenses and fire up an email notification.

23 Replies

  • CarbonKickstand's avatar
    CarbonKickstand
    Copper Contributor

    HiCarlos Gomez and everyone else! I recently wrote a blog post on this one and included my sample PowerShell code - comments welcome on the blog!! Thanks.

     

    https://itinvt.com/index.php/2021/11/21/email-alerts-for-low-office-365-licenses/

  • SimBur2365's avatar
    SimBur2365
    Brass Contributor
    There are quite a few scripts available now but I wanted to create my own to alert when the count of consumed licenses is getting close to or at 0.  I wouldn't expect anyone to be keeping more than 1 or 2 licenses free in a tenant (depending on the size of the org of course).  Who wants to pay for stuff you are not using?  In fact I think MS should look at allowing a negative buffer so that clients do not have to always have '1 or more spare'; let's face it that is forcing someone to pay for something they are not using yet right?  Anyway...

    The best way to run this is by creating an Azure Automation account (the future of task scheduler =).  In my script I use a free SendGrid account to send the email alert on port 587 (you cannot use outbound 25 from Azure without special permission), although now you can also add the SendGrid solution in Azure, then call it with variables as a playbook from an automation script (I haven't crossed that bridge yet!).  The email is not very pretty in basic text format, but it does the job.  You can easily schedule it in the automation account to run every hour or whatever suits your requirement.  As in the notes it is easily modifiable to alert when free licenses get low or high or both.  Hope it helps someone.

    https://www.howdoiuseacomputer.com/index.php/2021/09/12/azure-microsoft-365-licensing-alert/


  • GeeMan's avatar
    GeeMan
    Copper Contributor

    Carlos Gomez 

     

    Its not pretty but this will do what you want.  I have configured it for SPE_E3 sku but you can change it for which ever license type you want in the variables.  it will send an email when there are 10 licenses left.  Keep in mind if you use 10 licenses in between the script run cycles you might get notified too late. 

     

    $sku =Get-MsolAccountSku | where accountskuid -EQ "tennant:SPE_E3"
    $skuactive=$sku | select activeunits
    $skuconsumed=$sku | select consumedunits
    $skuadd10 = $skuconsumed.ConsumedUnits +10
    if ($skuadd10 -ge $skuactive.ActiveUnits) {Send-MailMessage -SmtpServer smtpserver01 -To geeman@maildomain.com -From geeman@maildomain.com -Body test -Subject test }

  • Kdships's avatar
    Kdships
    Copper Contributor

    Carlos Gomez, this is probably coming late. Just thought I should share this should anyone else needs it. https://insterswap.wordpress.com/2020/03/29/automatically-alert-your-team-when-your-tenant-is-running-low-or-out-of-office-365-license/

    Depending on how big or complicated your environment is, the alert script may require a little modification. Our need was just as simple as “tell us when our license is low or out”. As the saying goes, necessity is the mother of invention. Feel free to modify the script.

  • This issue, the lack of an Office 365 license consumption alert, is still unresolved (06/22/2018). 

    There is a feedback forum post for the task; https://feedback.azure.com/forums/169401-azure-active-directory/suggestions/33768322-get-low-license-count-notification 

    Please vote it up if you really want to see the change. 

     

    And as others have noted, you can set up a scheduled task to PowerShell an email to your relevant crew who may see going to the portal as an inconvenience. 

    I included my script below with <descriptions> of items that need filled in. 

    If you need help getting keys and such to encrypt passwords, try Share-gate or KeePass who provide good MS Online compatible encryption tools. 

     

    # 
    # Send_O365LicensingReport.ps1 
    #

    $key = (<integer array>); 
    $secureString = "<encrypted Password>" 
    $PWord = ConvertTo-SecureString $secureString -key $key; 
    $User = "<GlobalAdmin>@<company domain or .microsoftonline.com>"; 
    $Credential = New-Object –TypeName "System.Management.Automation.PSCredential" –ArgumentList $User, $PWord

    #Get the Office365 tenant credentials 
    $Office365credentials = Get-Credential $Credential;

    Connect-MsolService -Credential $Office365credentials; 
    write-host "Connecting to Microsoft SharePoint Online Service ..."

    [String]$SkuReport1 = Get-msolAccountSku | Select @{N='Product Name';E={switch ($_.AccountSkuId) { '<company domain>:ENTERPRISEPREMIUM' {'Office 365 Enterprise E5'} '<company domain>:POWER_BI_PRO' {'Power BI Pro'} '<company domain>:ENTERPRISEPACK' {'Office 365 Enterprise E3'} '<company domain>:SHAREPOINTSTORAGE' {'SharePoint Online Storage'} '<company domain>:POWER_BI_STANDARD' {'Power BI (free)'} '<company domain>:EMS' {'Enterprise Mobility + Security E3'} '<company domain>:MCOMEETADV' {'Audio Conferencing'} '<company domain>:DYN365_ENTERPRISE_SALES' {'Dynamics 365 for Sales Enterprise Edition'} '<company domain>:DYN365_ENTERPRISE_TEAM_MEMBERS' {'Dynamics 365 for Team Members Enterprise Edition'} default {'Unknown'} }}}, @{N='Active Units';E={$_.ActiveUnits}}, @{N='Consumed Units';E={$_.ConsumedUnits}}, @{Name = 'RemainingUnits'; Expression = {[string]([int]( $_.ActiveUnits - $_.ConsumedUnits))}}, @{N='Account SkuId'; E={$_.AccountSkuId}} | ConvertTo-Html

    Send-MailMessage -SmtpServer mail.<company domain> -To <recipient>@<company domain> -From <sender>@<company domain> -Subject "Consumed licenses report" -Body $SkuReport1 -BodyAsHtml

     

     

    • Adam Fowler's avatar
      Adam Fowler
      Iron Contributor

      A daily report via PowerShell is nice, but even better is an alert when certain numbers are hit based on previous reports! E.g. 0 remaining or 1 remaining.

  • In terms of alerts, no. A quick glance at the Admin portal or the Reports can give you this info. If you need it automated it really takes few lines of PowerShell code to check for available licenses and fire up an email notification.

    • LutzAndi475's avatar
      LutzAndi475
      Copper Contributor
      Hallo zusammen, Danke für die Super Unterstützung
    • Markus Kalmbach's avatar
      Markus Kalmbach
      Copper Contributor

      Hi everyone,

      even if this threat appears to be stuck or dead - I would be very interested to get the powershell code for getting alerts on low license counts - based on comparision of purchased and assigned licenses directly on the tenant level.

      Would be very appreciated.

      best regards

      Markus

      • VasilMichev's avatar
        VasilMichev
        MVP

        It takes two lines of PowerShell, and you have all the building blocks in the replies above.

    • Carlos Gomez's avatar
      Carlos Gomez
      Brass Contributor

      Hi Vasil,

       

      Do you know if there is a way to schedule the reports to be send? instead of going every day to open the admin portal and look for the report.

       

      Regards. 

      • BenStegink's avatar
        BenStegink
        Iron Contributor

        If you go the PowerShell route and want a schedule report you can always set it up on a server to run as a schedule task on a recurring basis. I've done a few reporting solutions this way to achieve a scheduled report :)

Resources