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 (1.5k points)

1 Answer

0 votes
by (182k 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

I'm trying to use "Before Modify Office 365" event to request approval for changes. It seems to be kicking off for the "After Create User" event. How do I request ... for default settings but if admins want to make a change then it goes out for approval.

asked Jul 20 by ComputerHabit (2.2k points)
0 votes
1 answer

Adaxes version is 2018.2. I have build a custom report, and I don't want the 'Name' column with the pictures to appear in it. But it seem to be mandatory, it is greyed ... . Is there a way to remove / hide / or change the mandatory attribute or column ? Thanks

asked Jan 9 by Isabelle (280 points)
0 votes
1 answer

I have a Powershell script running as a schedule task that is exporting user records. I have a custom attribute, positionPrimarySupervisor, that contains the DN of the user's ... supervisor. Can you provide me a script to get the information. Thanks... Sandra

asked Oct 8, 2015 by sandramnc (3.4k points)
0 votes
1 answer

I need a report that will show what O365 Licenses each user has based on Office. If can emailed or with in reports

asked Jan 17 by hgletifer (6.2k points)
0 votes
1 answer

When attempting to add an O365 license to an AD account via the Adaxes admin console, I noticed that it is missing some license types (e.g. Azure AD Premium P1). In ... Is there a way to configure Adaxes to pull all available license types from O365? Thanks!

asked Oct 22, 2019 by EricB (480 points)
2,241 questions
2,002 answers
5,483 comments
17,025 users