azurepowershellautomationoffice365sku

Transelate table values, better automation - MS365 SKU pr company in tenant - Powershell


I have a script to check SKUs pr company within the same tenant. Because sometimes there might be multiple companies sharing the same tenant, but maybe they want to get billed for licenses separately.

Right now my script works, but its not optimal.

First it does a check on the tenant. And then it prompts the user for a company name after listing all companies within the tenant.

The user then writes a name from the list.

And you will get output like below

Skus for: Company Name

Count Name                                 SKUName
----- ----                                 -------
    1 f8a1db68-be16-40ed-86d5-cb42ce701560 POWER_BI_PRO
    1 7ac9fe77-66b7-4e5e-9e46-10eed1cff547 DYN365_TEAM_MEMBERS
    5 f30db892-07e9-47e9-837c-80727f46fd3d FLOW_FREE, FLOW_FREE, FLOW_FREE, FLOW_FREE, FLOW_FREE
   21 4b9405b0-7788-4568-add1-99614e613b69 EXCHANGESTANDARD, EXCHANGESTANDARD, EXCHANGESTANDARD, EXCHANGESTANDARD, EXCHANGESTANDARD, EXCHANGESTANDARD, EXCHANGESTANDARD, EXCHANGESTANDARD, EXCHANGESTAN... 
   18 f245ecc8-75af-4f8e-b61f-27d8114de5f3 O365_BUSINESS_PREMIUM, O365_BUSINESS_PREMIUM, O365_BUSINESS_PREMIUM, O365_BUSINESS_PREMIUM, O365_BUSINESS_PREMIUM, O365_BUSINESS_PREMIUM, O365_BUSINESS_PREM...       
    3 a403ebcc-fae0-4ca2-8c8c-7a907fd6c235 POWER_BI_STANDARD, POWER_BI_STANDARD, POWER_BI_STANDARD
    5 710779e8-3d4a-4c88-adb9-386c958d1fdf TEAMS_EXPLORATORY, TEAMS_EXPLORATORY, TEAMS_EXPLORATORY, TEAMS_EXPLORATORY, TEAMS_EXPLORATORY
    6 3b555118-da6a-4418-894f-7df1e2096870 O365_BUSINESS_ESSENTIALS, O365_BUSINESS_ESSENTIALS, O365_BUSINESS_ESSENTIALS, O365_BUSINESS_ESSENTIALS, O365_BUSINESS_ESSENTIALS, O365_BUSINESS_ESSENTIALS
    2 1e1a282c-9c54-43a2-9310-98ef728faace DYN365_ENTERPRISE_SALES, DYN365_ENTERPRISE_SALES

What I hope to fix

I would like to translate the SKU names like below somehow. But I'm unsure about how to implement this into the script. I would also love for the SKUName to only show once. Not like the output above where it shows up as many times as the company have the sku.

I would also love it if it was possible to maybe make a loop that just printed out a table pr company in the tenant. instead of me having to write the names one by one in a prompt.

(script at the bottom of the question)

    $LicenseLookup = @{
    'SPZA_IW'                                 = 'App Connect Iw'
    'AAD_BASIC'                               = 'Azure Active Directory Basic'
    'AAD_PREMIUM'                             = 'Azure Active Directory Premium P1'
    'AAD_PREMIUM_P2'                          = 'Azure Active Directory Premium P2'
    'RIGHTSMANAGEMENT'                        = 'Azure Information Protection Plan 1'
    'MCOCAP'                                  = 'Common Area Phone'
    'MCOPSTNC'                                = 'Communications Credits'
    'DYN365_ENTERPRISE_PLAN1'                 = 'Dynamics 365 Customer Engagement Plan Enterprise Edition'
    'DYN365_ENTERPRISE_CUSTOMER_SERVICE'      = 'Dynamics 365 For Customer Service Enterprise Edition'
    'DYN365_FINANCIALS_BUSINESS_SKU'          = 'Dynamics 365 For Financials Business Edition'
    'DYN365_ENTERPRISE_SALES_CUSTOMERSERVICE' = 'Dynamics 365 For Sales And Customer Service Enterprise Edition'
    'DYN365_ENTERPRISE_SALES'                 = 'Dynamics 365 For Sales Enterprise Edition'
    'DYN365_ENTERPRISE_TEAM_MEMBERS'          = 'Dynamics 365 For Team Members Enterprise Edition'
    'DYN365_TEAM_MEMBERS'                     = 'Dynamics 365 Team Members'
    'Dynamics_365_for_Operations'             = 'Dynamics 365 Unf Ops Plan Ent Edition'
    'EMS'                                     = 'Enterprise Mobility + Security E3'
    'EMSPREMIUM'                              = 'Enterprise Mobility + Security E5'
    'EXCHANGESTANDARD'                        = 'Exchange Online (Plan 1)'
    'EXCHANGEENTERPRISE'                      = 'Exchange Online (Plan 2)'
    'EXCHANGEARCHIVE_ADDON'                   = 'Exchange Online Archiving For Exchange Online'
    'EXCHANGEARCHIVE'                         = 'Exchange Online Archiving For Exchange Server'
    'EXCHANGEESSENTIALS'                      = 'Exchange Online Essentials'
    'EXCHANGE_S_ESSENTIALS'                   = 'Exchange Online Essentials'
    'EXCHANGEDESKLESS'                        = 'Exchange Online Kiosk'
    'EXCHANGETELCO'                           = 'Exchange Online Pop'
    'INTUNE_A'                                = 'Intune'
    'M365EDU_A1'                              = 'Microsoft 365 A1'
    'M365EDU_A3_FACULTY'                      = 'Microsoft 365 A3 For Faculty'
    'M365EDU_A3_STUDENT'                      = 'Microsoft 365 A3 For Students'
    'M365EDU_A5_FACULTY'                      = 'Microsoft 365 A5 For Faculty'
    'M365EDU_A5_STUDENT'                      = 'Microsoft 365 A5 For Students'
    'O365_BUSINESS'                           = 'Microsoft 365 Apps For Business'
    'SMB_BUSINESS'                            = 'Microsoft 365 Apps For Business'
    'OFFICESUBSCRIPTION'                      = 'Microsoft 365 Apps For Enterprise'
    'MCOMEETADV'                              = 'Microsoft 365 Audio Conferencing'
    'MCOMEETADV_GOC'                          = 'Microsoft 365 Audio Conferencing For Gcc'
    'O365_BUSINESS_ESSENTIALS'                = 'Microsoft 365 Business Basic'
    'SMB_BUSINESS_ESSENTIALS'                 = 'Microsoft 365 Business Basic'
    'SPB'                                     = 'Microsoft 365 Business Premium'
    'O365_BUSINESS_PREMIUM'                   = 'Microsoft 365 Business Standard'
    'SMB_BUSINESS_PREMIUM'                    = 'Microsoft 365 Business Standard'
    'MCOPSTN_5'                               = 'Microsoft 365 Domestic Calling Plan (120 Minutes)'
    'SPE_E3'                                  = 'Microsoft 365 E3'
    'SPE_E3_USGOV_DOD'                        = 'Microsoft 365 E3_Usgov_Dod'
    'SPE_E3_USGOV_GCCHIGH'                    = 'Microsoft 365 E3_Usgov_Gcchigh'
    'SPE_E5'                                  = 'Microsoft 365 E5'
    'INFORMATION_PROTECTION_COMPLIANCE'       = 'Microsoft 365 E5 Compliance'
    'IDENTITY_THREAT_PROTECTION'              = 'Microsoft 365 E5 Security'
    'IDENTITY_THREAT_PROTECTION_FOR_EMS_E5'   = 'Microsoft 365 E5 Security For Ems E5'
    'M365_F1'                                 = 'Microsoft 365 F1'
    'SPE_F1'                                  = 'Microsoft 365 F3'
    'M365_G3_GOV'                             = 'Microsoft 365 Gcc G3'
    'MCOEV'                                   = 'Microsoft 365 Phone System'
    'PHONESYSTEM_VIRTUALUSER'                 = 'Microsoft 365 Phone System - Virtual User'
    'MCOEV_DOD'                               = 'Microsoft 365 Phone System For Dod'
    'MCOEV_FACULTY'                           = 'Microsoft 365 Phone System For Faculty'
    'MCOEV_GOV'                               = 'Microsoft 365 Phone System For Gcc'
    'MCOEV_GCCHIGH'                           = 'Microsoft 365 Phone System For Gcchigh'
    'MCOEVSMB_1'                              = 'Microsoft 365 Phone System For Small And Medium Business'
    'MCOEV_STUDENT'                           = 'Microsoft 365 Phone System For Students'
    'MCOEV_TELSTRA'                           = 'Microsoft 365 Phone System For Telstra'
    'MCOEV_USGOV_DOD'                         = 'Microsoft 365 Phone System_Usgov_Dod'
    'MCOEV_USGOV_GCCHIGH'                     = 'Microsoft 365 Phone System_Usgov_Gcchigh'
    'WIN_DEF_ATP'                             = 'Microsoft Defender Advanced Threat Protection'
    'CRMSTANDARD'                             = 'Microsoft Dynamics Crm Online'
    'CRMPLAN2'                                = 'Microsoft Dynamics Crm Online Basic'
    'FLOW_FREE'                               = 'Microsoft Flow Free'
    'INTUNE_A_D_GOV'                          = 'Microsoft Intune Device For Government'
    'POWERAPPS_VIRAL'                         = 'Microsoft Power Apps Plan 2 Trial'
    'TEAMS_FREE'                              = 'Microsoft Team (Free)'
    'TEAMS_EXPLORATORY'                       = 'Microsoft Teams Exploratory'
    'IT_ACADEMY_AD'                           = 'Ms Imagine Academy'
    'ENTERPRISEPREMIUM_FACULTY'               = 'Office 365 A5 For Faculty'
    'ENTERPRISEPREMIUM_STUDENT'               = 'Office 365 A5 For Students'
    'EQUIVIO_ANALYTICS'                       = 'Office 365 Advanced Compliance'
    'ATP_ENTERPRISE'                          = 'Microsoft Defender for Office 365 (Plan 1)'
    'STANDARDPACK'                            = 'Office 365 E1'
    'STANDARDWOFFPACK'                        = 'Office 365 E2'
    'ENTERPRISEPACK'                          = 'Office 365 E3'
    'DEVELOPERPACK'                           = 'Office 365 E3 Developer'
    'ENTERPRISEPACK_USGOV_DOD'                = 'Office 365 E3_Usgov_Dod'
    'ENTERPRISEPACK_USGOV_GCCHIGH'            = 'Office 365 E3_Usgov_Gcchigh'
    'ENTERPRISEWITHSCAL'                      = 'Office 365 E4'
    'ENTERPRISEPREMIUM'                       = 'Office 365 E5'
    'ENTERPRISEPREMIUM_NOPSTNCONF'            = 'Office 365 E5 Without Audio Conferencing'
    'DESKLESSPACK'                            = 'Office 365 F3'
    'ENTERPRISEPACK_GOV'                      = 'Office 365 Gcc G3'
    'MIDSIZEPACK'                             = 'Office 365 Midsize Business'
    'LITEPACK'                                = 'Office 365 Small Business'
    'LITEPACK_P2'                             = 'Office 365 Small Business Premium'
    'WACONEDRIVESTANDARD'                     = 'Onedrive For Business (Plan 1)'
    'WACONEDRIVEENTERPRISE'                   = 'Onedrive For Business (Plan 2)'
    'POWER_BI_STANDARD'                       = 'Power Bi (Free)'
    'POWER_BI_ADDON'                          = 'Power Bi For Office 365 Add-On'
    'POWER_BI_PRO'                            = 'Power Bi Pro'
    'PROJECTCLIENT'                           = 'Project For Office 365'
    'PROJECTESSENTIALS'                       = 'Project Online Essentials'
    'PROJECTPREMIUM'                          = 'Project Online Premium'
    'PROJECTONLINE_PLAN_1'                    = 'Project Online Premium Without Project Client'
    'PROJECTPROFESSIONAL'                     = 'Microsoft Project Plan 3'
    'PROJECTONLINE_PLAN_2'                    = 'Project Online With Project For Office 365'
    'SHAREPOINTSTANDARD'                      = 'Sharepoint Online (Plan 1)'
    'SHAREPOINTENTERPRISE'                    = 'Sharepoint Online (Plan 2)'
    'MCOIMP'                                  = 'Skype For Business Online (Plan 1)'
    'MCOSTANDARD'                             = 'Skype For Business Online (Plan 2)'
    'MCOPSTN2'                                = 'Skype For Business Pstn Domestic And International Calling'
    'MCOPSTN1'                                = 'Skype For Business Pstn Domestic Calling'
    'MCOPSTN5'                                = 'Skype For Business Pstn Domestic Calling (120 Minutes)'
    'MCOPSTNEAU2'                             = 'Telstra Calling For O365'
    'TOPIC_EXPERIENCES'                       = 'Topic Experiences'
    'VISIOONLINE_PLAN1'                       = 'Visio Online Plan 1'
    'VISIOCLIENT'                             = 'Visio Online Plan 2'
    'VISIOCLIENT_GOV'                         = 'Visio Plan 2 For Gov'
    'WIN10_PRO_ENT_SUB'                       = 'Windows 10 Enterprise E3'
    'WIN10_VDA_E3'                            = 'Windows 10 Enterprise E3'
    'WIN10_VDA_E5'                            = 'Windows 10 Enterprise E5'
    'WINDOWS_STORE'                           = 'Windows Store For Business'
    'RMSBASIC'                                = 'Azure Information Protection Basic'
    'UNIVERSAL_PRINT_M365'                    = 'Universal Print'
    'RIGHTSMANAGEMENT_ADHOC'                  = 'Rights Management Service Basic Content Protection'
    'SKU_Dynamics_365_for_HCM_Trial'          = 'Dynamics 365 for Talent'
    'PROJECT_P1'                              = 'Project Plan 1'
    'PROJECT_PLAN1_DEPT'                      = 'Project Plan  1 (Self Service)'
    'SHAREPOINTSTORAGE'                       = 'Microsoft Office 365 Extra File Storage'
    'NONPROFIT_PORTAL'                        = 'Non Profit Portal'
    'MDE_SMB'                                 = 'Microsoft Defender for Endpoint (Business Premium)'
}

The current script i use

below is the script as it is today. and how i use it. keep in mind that this is made by me (a noob). so some things might not make too much sense as to why i do things as i do. any tips would be welcome.

    cls
    
    Connect-AzureAD
    
    $Report = [System.Collections.Generic.List[Object]]::new() # Create output file 
    $Skus = Get-AzureADSubscribedSku | Select Sku*, ConsumedUnits 
    ForEach ($Sku in $Skus) {
        Write-Host "Processing license holders for" $Sku.SkuPartNumber
        $SkuUsers = Get-AzureADUser -All $True | ? { $_.AssignedLicenses -Match $Sku.SkuId }
        ForEach ($User in $SkuUsers) {
            $ReportLine = [PSCustomObject] @{
                User        = $User.DisplayName 
                UPN         = $User.UserPrincipalName
                Companyname = $User.Companyname
                Country     = $User.Country
                SKU         = $Sku.SkuId
                SKUName     = $Sku.SkuPartNumber
            }
            $Report.Add($ReportLine) 
        }
    }
    
    
        cls
    
    $commands = {
    
    #Collects all companies within the tenant
    $companies = $Report | Select-Object Companyname -Unique
    write-host "Below is a list of all Companies in the tenant";
     
    $companies | Out-Host
    $userinput = "FALSE"
    $userinput = Read-Host "Write the name of the company you want to check:";
    
    #just some padding
    write-host " "
    write-host " "
    write-host " "
    write-host " "  
    write-host "Skus for: $userinput" #adding a title based on what you write.
    $Report | Where-Object Companyname -like $userinput | Group-Object -Property SKU | Select-Object Count, Name, @{Name = 'SKUName' ; expression = { ($_.Group.SKUName) -join ', ' } } | Format-Table
    
        #prompts the user for another check.
        $again = Read-Host "again?"
        if ($again -eq "y"){
            &$commands
        } else {
            Write-Host "exited..."    
        }
    }
    
    &$commands 

Outro

I hope what I wrote was understandable. My English is not the best,so for that I'm sorry.

Any help or tips regarding what I asked for would be amazing. Thanks!


Solution

  • the solution was as @mathisas R. Jenssen posted.

    and then i just ran this with a very ugly loop throughout the list of companynames in the tenant. below is the part of the script that changed. if you are running this you should run this with the $report and $skus foreach loop like before.

    but below u add this:

    
    $LicenseLookup = @{
        'SPZA_IW'                                 = 'App Connect Iw'
        'AAD_BASIC'                               = 'Azure Active Directory Basic'
        'AAD_PREMIUM'                             = 'Azure Active Directory Premium P1'
        'AAD_PREMIUM_P2'                          = 'Azure Active Directory Premium P2'
        'RIGHTSMANAGEMENT'                        = 'Azure Information Protection Plan 1'
        'MCOCAP'                                  = 'Common Area Phone'
        'MCOPSTNC'                                = 'Communications Credits'
        'DYN365_ENTERPRISE_PLAN1'                 = 'Dynamics 365 Customer Engagement Plan Enterprise Edition'
        'DYN365_ENTERPRISE_CUSTOMER_SERVICE'      = 'Dynamics 365 For Customer Service Enterprise Edition'
        'DYN365_FINANCIALS_BUSINESS_SKU'          = 'Dynamics 365 For Financials Business Edition'
        'DYN365_ENTERPRISE_SALES_CUSTOMERSERVICE' = 'Dynamics 365 For Sales And Customer Service Enterprise Edition'
        'DYN365_ENTERPRISE_SALES'                 = 'Dynamics 365 For Sales Enterprise Edition'
        'DYN365_ENTERPRISE_TEAM_MEMBERS'          = 'Dynamics 365 For Team Members Enterprise Edition'
        'DYN365_TEAM_MEMBERS'                     = 'Dynamics 365 Team Members'
        'Dynamics_365_for_Operations'             = 'Dynamics 365 Unf Ops Plan Ent Edition'
        'EMS'                                     = 'Enterprise Mobility + Security E3'
        'EMSPREMIUM'                              = 'Enterprise Mobility + Security E5'
        'EXCHANGESTANDARD'                        = 'Exchange Online (Plan 1)'
        'EXCHANGEENTERPRISE'                      = 'Exchange Online (Plan 2)'
        'EXCHANGEARCHIVE_ADDON'                   = 'Exchange Online Archiving For Exchange Online'
        'EXCHANGEARCHIVE'                         = 'Exchange Online Archiving For Exchange Server'
        'EXCHANGEESSENTIALS'                      = 'Exchange Online Essentials'
        'EXCHANGE_S_ESSENTIALS'                   = 'Exchange Online Essentials'
        'EXCHANGEDESKLESS'                        = 'Exchange Online Kiosk'
        'EXCHANGETELCO'                           = 'Exchange Online Pop'
        'INTUNE_A'                                = 'Intune'
        'M365EDU_A1'                              = 'Microsoft 365 A1'
        'M365EDU_A3_FACULTY'                      = 'Microsoft 365 A3 For Faculty'
        'M365EDU_A3_STUDENT'                      = 'Microsoft 365 A3 For Students'
        'M365EDU_A5_FACULTY'                      = 'Microsoft 365 A5 For Faculty'
        'M365EDU_A5_STUDENT'                      = 'Microsoft 365 A5 For Students'
        'O365_BUSINESS'                           = 'Microsoft 365 Apps For Business'
        'SMB_BUSINESS'                            = 'Microsoft 365 Apps For Business'
        'OFFICESUBSCRIPTION'                      = 'Microsoft 365 Apps For Enterprise'
        'MCOMEETADV'                              = 'Microsoft 365 Audio Conferencing'
        'MCOMEETADV_GOC'                          = 'Microsoft 365 Audio Conferencing For Gcc'
        'O365_BUSINESS_ESSENTIALS'                = 'Microsoft 365 Business Basic'
        'SMB_BUSINESS_ESSENTIALS'                 = 'Microsoft 365 Business Basic'
        'SPB'                                     = 'Microsoft 365 Business Premium'
        'O365_BUSINESS_PREMIUM'                   = 'Microsoft 365 Business Standard'
        'SMB_BUSINESS_PREMIUM'                    = 'Microsoft 365 Business Standard'
        'MCOPSTN_5'                               = 'Microsoft 365 Domestic Calling Plan (120 Minutes)'
        'SPE_E3'                                  = 'Microsoft 365 E3'
        'SPE_E3_USGOV_DOD'                        = 'Microsoft 365 E3_Usgov_Dod'
        'SPE_E3_USGOV_GCCHIGH'                    = 'Microsoft 365 E3_Usgov_Gcchigh'
        'SPE_E5'                                  = 'Microsoft 365 E5'
        'INFORMATION_PROTECTION_COMPLIANCE'       = 'Microsoft 365 E5 Compliance'
        'IDENTITY_THREAT_PROTECTION'              = 'Microsoft 365 E5 Security'
        'IDENTITY_THREAT_PROTECTION_FOR_EMS_E5'   = 'Microsoft 365 E5 Security For Ems E5'
        'M365_F1'                                 = 'Microsoft 365 F1'
        'SPE_F1'                                  = 'Microsoft 365 F3'
        'M365_G3_GOV'                             = 'Microsoft 365 Gcc G3'
        'MCOEV'                                   = 'Microsoft 365 Phone System'
        'PHONESYSTEM_VIRTUALUSER'                 = 'Microsoft 365 Phone System - Virtual User'
        'MCOEV_DOD'                               = 'Microsoft 365 Phone System For Dod'
        'MCOEV_FACULTY'                           = 'Microsoft 365 Phone System For Faculty'
        'MCOEV_GOV'                               = 'Microsoft 365 Phone System For Gcc'
        'MCOEV_GCCHIGH'                           = 'Microsoft 365 Phone System For Gcchigh'
        'MCOEVSMB_1'                              = 'Microsoft 365 Phone System For Small And Medium Business'
        'MCOEV_STUDENT'                           = 'Microsoft 365 Phone System For Students'
        'MCOEV_TELSTRA'                           = 'Microsoft 365 Phone System For Telstra'
        'MCOEV_USGOV_DOD'                         = 'Microsoft 365 Phone System_Usgov_Dod'
        'MCOEV_USGOV_GCCHIGH'                     = 'Microsoft 365 Phone System_Usgov_Gcchigh'
        'WIN_DEF_ATP'                             = 'Microsoft Defender Advanced Threat Protection'
        'CRMSTANDARD'                             = 'Microsoft Dynamics Crm Online'
        'CRMPLAN2'                                = 'Microsoft Dynamics Crm Online Basic'
        'FLOW_FREE'                               = 'Microsoft Flow Free'
        'INTUNE_A_D_GOV'                          = 'Microsoft Intune Device For Government'
        'POWERAPPS_VIRAL'                         = 'Microsoft Power Apps Plan 2 Trial'
        'TEAMS_FREE'                              = 'Microsoft Team (Free)'
        'TEAMS_EXPLORATORY'                       = 'Microsoft Teams Exploratory'
        'IT_ACADEMY_AD'                           = 'Ms Imagine Academy'
        'ENTERPRISEPREMIUM_FACULTY'               = 'Office 365 A5 For Faculty'
        'ENTERPRISEPREMIUM_STUDENT'               = 'Office 365 A5 For Students'
        'EQUIVIO_ANALYTICS'                       = 'Office 365 Advanced Compliance'
        'ATP_ENTERPRISE'                          = 'Microsoft Defender for Office 365 (Plan 1)'
        'STANDARDPACK'                            = 'Office 365 E1'
        'STANDARDWOFFPACK'                        = 'Office 365 E2'
        'ENTERPRISEPACK'                          = 'Office 365 E3'
        'DEVELOPERPACK'                           = 'Office 365 E3 Developer'
        'ENTERPRISEPACK_USGOV_DOD'                = 'Office 365 E3_Usgov_Dod'
        'ENTERPRISEPACK_USGOV_GCCHIGH'            = 'Office 365 E3_Usgov_Gcchigh'
        'ENTERPRISEWITHSCAL'                      = 'Office 365 E4'
        'ENTERPRISEPREMIUM'                       = 'Office 365 E5'
        'ENTERPRISEPREMIUM_NOPSTNCONF'            = 'Office 365 E5 Without Audio Conferencing'
        'DESKLESSPACK'                            = 'Office 365 F3'
        'ENTERPRISEPACK_GOV'                      = 'Office 365 Gcc G3'
        'MIDSIZEPACK'                             = 'Office 365 Midsize Business'
        'LITEPACK'                                = 'Office 365 Small Business'
        'LITEPACK_P2'                             = 'Office 365 Small Business Premium'
        'WACONEDRIVESTANDARD'                     = 'Onedrive For Business (Plan 1)'
        'WACONEDRIVEENTERPRISE'                   = 'Onedrive For Business (Plan 2)'
        'POWER_BI_STANDARD'                       = 'Power Bi (Free)'
        'POWER_BI_ADDON'                          = 'Power Bi For Office 365 Add-On'
        'POWER_BI_PRO'                            = 'Power Bi Pro'
        'PROJECTCLIENT'                           = 'Project For Office 365'
        'PROJECTESSENTIALS'                       = 'Project Online Essentials'
        'PROJECTPREMIUM'                          = 'Project Online Premium'
        'PROJECTONLINE_PLAN_1'                    = 'Project Online Premium Without Project Client'
        'PROJECTPROFESSIONAL'                     = 'Microsoft Project Plan 3'
        'PROJECTONLINE_PLAN_2'                    = 'Project Online With Project For Office 365'
        'SHAREPOINTSTANDARD'                      = 'Sharepoint Online (Plan 1)'
        'SHAREPOINTENTERPRISE'                    = 'Sharepoint Online (Plan 2)'
        'MCOIMP'                                  = 'Skype For Business Online (Plan 1)'
        'MCOSTANDARD'                             = 'Skype For Business Online (Plan 2)'
        'MCOPSTN2'                                = 'Skype For Business Pstn Domestic And International Calling'
        'MCOPSTN1'                                = 'Skype For Business Pstn Domestic Calling'
        'MCOPSTN5'                                = 'Skype For Business Pstn Domestic Calling (120 Minutes)'
        'MCOPSTNEAU2'                             = 'Telstra Calling For O365'
        'TOPIC_EXPERIENCES'                       = 'Topic Experiences'
        'VISIOONLINE_PLAN1'                       = 'Visio Online Plan 1'
        'VISIOCLIENT'                             = 'Visio Online Plan 2'
        'VISIOCLIENT_GOV'                         = 'Visio Plan 2 For Gov'
        'WIN10_PRO_ENT_SUB'                       = 'Windows 10 Enterprise E3'
        'WIN10_VDA_E3'                            = 'Windows 10 Enterprise E3'
        'WIN10_VDA_E5'                            = 'Windows 10 Enterprise E5'
        'WINDOWS_STORE'                           = 'Windows Store For Business'
        'RMSBASIC'                                = 'Azure Information Protection Basic'
        'UNIVERSAL_PRINT_M365'                    = 'Universal Print'
        'RIGHTSMANAGEMENT_ADHOC'                  = 'Rights Management Service Basic Content Protection'
        'SKU_Dynamics_365_for_HCM_Trial'          = 'Dynamics 365 for Talent'
        'PROJECT_P1'                              = 'Project Plan 1'
        'PROJECT_PLAN1_DEPT'                      = 'Project Plan  1 (Self Service)'
        'SHAREPOINTSTORAGE'                       = 'Microsoft Office 365 Extra File Storage'
        'NONPROFIT_PORTAL'                        = 'Non Profit Portal'
        'MDE_SMB'                                 = 'Microsoft Defender for Endpoint (Business Premium)'
    }
    
    cls
    
    #List of company names in the tenant
    $Companies = $Report | Select-Object Companyname -Unique
    
    #horrible improvised "for" loop that goes through the list of companynames
    $counter = 0 #starting at pos [0]
    
    foreach ($company in $Companies) {
        #prints the current companyname
        $Companies.companyname[$counter]
    
        #formatting the table for the current companyname[i] where it shows count, name, and SKUName
        $Report | Where-Object Companyname -like $Companies.companyname[$counter] | Group-Object -Property SKU | Select-Object Count, Name, @{Name = 'SKU Name' ; expression = { ($LicenseLookup[$_.Group.SKUName]) -join ', ' } } | Format-Table
        
        #then moves down 1 pos in the current companyname[i]
        $counter = $counter + 1
        Write-Host "--------------------------------------------------------------------------------------------"
    }