Forum Discussion
Get email alerts for low than 50 free Office 365 licenses
You can simply use below logic - Get the number of consumed units and based on the consumption call email alert. You can extend below logic for your script by adding some error handling and email function.
Change the tenant name and sku type - you want to monitor
$GetConsumedUnits=(Get-MsolAccountSku | where {$_.AccountSkuId -eq "tenant:ENTERPRISEPACK"}) | Select-Object ConsumedUnits
If ($GetConsumedUnits.ConsumedUnits -gt xx)
{
Call Email Alert Function
}
Cheers,
H,
I'm schedule to run weekly and send an email.
Get-MsolAccountSku | select ActiveUnits, ConsumedUnits, @{n='AvailableUnits';e={($_.ActiveUnits - $_.ConsumedUnits)}}, AccountSkuId
But how do i email only Availableunit under 5 ?
- Slasky86Aug 25, 2021Copper Contributor
You simply store the results of that in a variable, then you can do a foreach loop for each line, and do some fancy percentage maths to see if anyone is over a certain level, then send a mail based on that.
type:
$licenseinfo = Get-MsolAccountSku | select ActiveUnits, ConsumedUnits, @{n='AvailableUnits';e={($_.ActiveUnits - $_.ConsumedUnits)}}, AccountSkuId
foreach ($sku in $licenseinfo) {
$percentageused = $sku.ConsumedUnits / $sku.ActiveUnits * 100if ($percentageused -ge 80) {
#send mail function
}
}- AusSupport180Sep 16, 2021Brass ContributorThanks
- SimBur2365Sep 13, 2021Brass ContributorHi, here is a script you can run from Azure Automation... you can now also create a free sendgrid account directly in Azure Solutions to call from a runbook. Cheers 😃
https://www.howdoiuseacomputer.com/index.php/2021/09/12/azure-microsoft-365-licensing-alert/