public/Check-O365Licenses.ps1
<#
.Synopsis Displays the current license status for your organization and outputs the info in your current powershell session. .Description This powershell cmdlet will check the status of your Office 365 Licenses and output the total number of licenses your organization currently has available, has used, and owns. .Example Check-O365Licenses Description ----------- Issuing this command requires no parameters. A table will be displayed with you license information. #> Function Check-O365Licenses{ [cmdletbinding()] Param () # End of Parameters Process { Test-O365Connection $SourceData = Get-MsolAccountSku $Licenses = @() #Array of license info we are customizing for output #Creating array to display license info (this just adds to the Get-MsolAccount by showing available licenses) $results = foreach ($obj in $SourceData) { $name = $obj.AccountSkuId $pos = $name.IndexOf(":") $object = New-Object psobject -Property @{ LicenseType = $name.Substring($pos+1) Available_Licenses = ($obj.ActiveUnits - $obj.ConsumedUnits)#.ToString("000") Total_Licenses = $obj.ActiveUnits#.ToString("000") Used_Licenses = $obj.ConsumedUnits#.ToString("000") } $Licenses += $object } $Licenses | select LicenseType,Available_Licenses,Total_Licenses,Used_Licenses | FT LicenseType,Available_Licenses,Used_Licenses,Total_Licenses }#End Process } |