0 votes

I'm trying to retrive the Microsoft 365 License product name in a report as the 'Office 365 License' attribute in Adaxes shows each individual licensed product e.g. Exchange etc. We're trying to get a report of each of the different license types into a report in Adaxes for additional action.

So far I have the below however it's not retrieving values even though if a run the script in powershell it works perfectly. Product names from the article here

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

$user = $Context.BindToObjectByDN("%distinguishedName%")
$Context.GetOffice365Credential($user)

Connect-MsolService -Credential

$MSOLUser = Get-MsolUser -UserPrincipalName "%userPrincipalName%"
$Licenses = ($MSOLUser.Licenses.AccountSkuId).Trim("%company%:")

$productnames = @()
Foreach ($License in $Licenses) {
    If ($License -eq "ENTERPRISEPACK") {$productnames += "Office 365 E3"}
    Elseif ($License -eq "DESKLESSPACK") {$productnames += "Office 365 F3"}
    ElseIf ($License -eq "SPE_E3") {$productnames += "Microsoft 365 E3"}
    ElseIf ($License -eq "SPE_F1") {$productnames += "Microsoft 365 F3"}
    }
$productnames = $productnames -join ", "


$Context.Value = $productnames
by (260 points)

1 Answer

0 votes
by (304k points)
selected by
Best answer

Hello Richard,

Use the below script to add names of assigned Microsoft 365 licenses to the custom column. The column type should be Text.

$ADObject = $Context.GetADObject()
try
{
    $microsoft365properties = $ADObject.GetOffice365Properties2()
}
catch
{
    $microsoft365properties = $NULL
}

if ($NULL -ne $microsoft365properties)
{
    $licenses = @()
    foreach ($license in $microsoft365properties.Licenses)
    {
        if (!$license.Assigned)
        {
            continue
        }

        $licenseName = $license.Sku.DisplayName
        $licenses += $licenseName
    }

    $stringValue = [System.String]::Join(";", $licenses)
    $Context.Value = $stringValue
}
else
{
    $Context.Value = "No tenant associated with user"
}

Related questions

0 votes
1 answer

Hi I'm trying to product a report to show the users with either E3, F3 or F5 licenses. If I add the Adaxes "Microsoft 365 Licenses" attribute directly to the report then ... from the user and show a nice "Microsoft E3" etc value. Is this possible? Thanks

asked Sep 27, 2021 by chappers77 (2.0k points)
0 votes
1 answer

Hi, I try to make a report for our SAM to show all users with a specific license. But I fail to even find anything. I tried, among many ... .DirectorySearcher.AppendFilter("(adm-O365AccountLicenses=POWER_BI_STANDARD)") But I get nothing. Please advice.

asked May 20, 2021 by KristofferJ (80 points)
0 votes
1 answer

Our Microsoft 365 licensing changed recently. All of our end users has a particular license that is no longer valid (ENTERPRISEPREMIUM = Office 365 E5). I need to give everyone that ... the same time, remove the old license. How can this be set up in Adaxes?

asked 4 days ago by RayBilyk (260 points)
0 votes
1 answer

Is there a way to add Microsoft Defender for Office 365 Plan 2 licenses from Adaxes? Currently it is not showing in the list of available licenses to modify. The endpoint ... the E3 license is showing up no problem, just not the standalone one for O365.

asked Aug 20, 2024 by Alex23 (50 points)
0 votes
1 answer

We need to capture the Office365 (if any) on the user account before we disable. These are accounts taht are temps or contractors that we disabled and re enable for ... Example of group name is Office-E3-EXO and we want to capture it to CustomAttributeText31

asked Aug 4, 2020 by willy-wally (3.2k points)
3,731 questions
3,409 answers
8,625 comments
550,184 users