Tuesday, January 7, 2020

Azure Simple Users License Report

Below script will provide simple snapshot of Azure License status for your organization by using MsolService to connect to Azure Directory services. Script is built with few simple functions to gather license information.
Script also have option to review output within Grid view as shown; which is super useful way of sorting and saving output if desired to CSV or excel file.
Let me know if you find it handy.





<#    

.NOTES
#=============================================
# Script      : Get-Azure-License-Status-Report.ps1
# Created     : ISE 3.0 
# Author(s)   : Casey.Dedeal 
# Date        : 01/06/2020 08:53:36 
# Org         : ETC Solutions
# File Name   : Get-Azure-License-Status-Report.ps1
# Comments    : Get-Azure-License-Status-Report.ps1
# Assumptions : Running from administrator Server
#==============================================

SYNOPSIS           : Get-Azure-License-Report-Status.ps1
DESCRIPTION        : Get-Azure-License-Report-Status.ps1
Acknowledgements   : Open license
Limitations        : None
Known issues       : None
Credits            : https://simplepowershell.blogspot.com

.EXAMPLE
  .\Get-Azure-License-Status-Report.ps1

  MAP:
  -----------
  #(1)_.Function-EXO-MSOL-Connect-V1
  #(2)_.Function-Get-TimeStamp
  #(3)_.Adding Options and Displaying results
  (4)_.Run License Status Report
#>


#(1)_.Function-EXO-MSOL-Connect-V1
function Function-CON-AZURE-ADD-V1
{

Try{
$URL   = 'https://outlook.office365.com/powershell-liveid/'
$Luser = $env:USERNAME
$Mail  = '@'
$UPN   = $Luser + $Mail
$UserCredential = Get-Credential $UPN
Connect-MsolService -Credential $UserCredential -ErrorAction Stop

}Catch{
  Write-Warning 'Error has occoured'
  Write-host "Problem FOUND: $($PSItem.ToString())" -f red -b White
}}


#(2)_.Function-Get-TimeStamp
function Function-Get-TimeStamp {
   
  return "[{0:MM/dd/yy} {0:HH:mm:ss}]" -f (Get-Date)
   
}

#(3)_.Function-Get-License-Status-Report
function Function-Get-License-Status-Report
{
$Options =@(

'AccountName',
'AccountSkuID',
'ActiveUnits',
'ConsumedUnits',
'SuspendedUnits',
'WarningUnits'
)

Try{

Function-CON-AZURE-ADD-V1
$status = Get-MsolAccountSku -ErrorAction Stop | Select $Options

Write-host '++++++++++++++++++++++++++++++++++++++++' -f Yellow
write-host 'O365 License status Summary Report'
Write-Host 'Report run:' -NoNewline; Function-Get-TimeStamp
Write-host '++++++++++++++++++++++++++++++++++++++++' -f Yellow
$status | ft -AutoSize
Write-host '++++++++++++++++++++++++++++++++++++++++' -f Cyan
Read-host 'Press <ENTER> to open report in GridView'
$status | Out-GridView

}Catch{
  Write-Warning 'Error has occoured'
  Write-host "Problem FOUND: $($PSItem.ToString())" -f red -b White
}}

#(4)_.Run License Status Report
Function-Get-License-Status-Report 




Casey, Dedeal
Azure Solutions Architect
AWS Certified Cloud Practitioner

https://simplepowershell.blogspot.com
https://cloudsec365.blogspot.com
https://msazure365.blogspot.com
https://twitter.com/Message_Talk

NoSpam@Oz.DeDeal@CloudSec365.onmicrosoft.com
P: 202-656-9206

No comments:

Post a Comment