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 (220 points)

1 Answer

0 votes
by (208k 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 by chappers77 (1k 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 by KristofferJ (80 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)
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, 2020 by ComputerHabit (790 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, 2020 by Isabelle (50 points)
2,572 questions
2,315 answers
6,171 comments
750,112 users