-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Get-O365Licenses.ps1
40 lines (36 loc) · 1.29 KB
/
Get-O365Licenses.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
function Get-O365Licenses {
<#
.SYNOPSIS
Gets the current O365 license status
.DESCRIPTION
Connects to O365 tenancy and gets the current license total, used and remaining counts and outputs to console.
.EXAMPLE
Get-O365Licenses
.EXAMPLE
Get-O365Licnses | Out-GridView
.OUTPUTS
Name LicensesTotal LicensesUsed LicensesRemaining
---- ------------- ------------ -----------------
ENTERPRISEPREMIUM 25 5 20
POWERAPPS_INDIVIDUAL_USER 10000 2 9998
YAMMER_ENTERPRISE_STANDALONE 1 0 1
ENTERPRISEPACK 52 41 11
.NOTES
Must be connected to AzureAD to run this script
Use the Connect-AzureAD cmdlet to connect
#>
[CmdletBinding()]
Param (
)
process {
$skus = Get-AzureADSubscribedSku
foreach ($sku in $skus) {
[PSCustomObject]@{
Name = $sku.skupartnumber
LicensesTotal = $sku.prepaidunits.enabled
LicensesUsed = $sku.consumedunits
LicensesRemaining = ($sku.prepaidunits.enabled) - ($sku.consumedunits)
}
}
}
}