Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,448 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi everyone,
I am trying to export some information from AAD via MSGraph PowerShell. I am not sure if the information I want to export can be done this way and hoping someone can help me or at least confirm if it's possible to export it.
1- Is it possible to export on prem AD Extension Attributes? ie ExtensionAttribute2, ExtensionAttribute3 (They are already syncing to AAD)
2- Can you include direct and group level license assignment information?
Below is the script I am using but couldn't get these 2 options working and not sure if it can be done.
$users = @()
$members = Get-MgUser -All
foreach ($member in $members) {
$user = Get-MgUser -UserId $member.Id -Property ID, DisplayName, UserPrincipalName, companyName | Select-Object ID, DisplayName, UserPrincipalName, companyName
$licenses = $null
$licenses = (Get-MgUserLicenseDetail -UserId $User.id).SkuPartNumber
foreach ($license in $licenses ) {
#Write-Host "Licenses found for $($User.DisplayName): $license"
if($license -ne 'FLOW_FREE'){
if($license -ne 'POWER_BI_STANDARD'){
$users += [PSCustomObject]@{
ID = $user.ID
USERPRINCIPALNAME = $user.UserPrincipalName
Name = $user.DisplayName
Licenses = $license
companyName = $user.CompanyName}
}
}
}
}
Thanks