Export users

Rising Flight 5,216 Reputation points
2024-08-28T20:39:39.7066667+00:00

Hi all,

We create users in on-premises Active Directory, and they are synchronized to Azure AD. I have two requirements:For every user in Azure, I see an Object ID. Is this Object ID coming from the on-premises Active Directory, or is it assigned by Azure AD?

is the below syntax correct, please correct me.

$users = Get-MgUser -All | ForEach-Object {
    $licenses = (Get-MgUserLicenseDetail -UserId $_.Id).SkuPartNumber -join "; "
    [PSCustomObject]@{
        ObjectId        = $_.Id
        UserPrincipalName = $_.UserPrincipalName
        Email           = $_.Mail
        DisplayName     = $_.DisplayName
        License         = $licenses
    }
}
$users | Export-Csv -Path "C:\temp\output.csv" -NoTypeInformation

I have an application that needs to fetch Azure AD users along with their Object IDs. I have created an Azure App Registration and given it the User.Read (delegated) Graph API permission. Is this API permission sufficient to get Azure AD users along with their Object IDs?

Exchange Online
Exchange Online
A Microsoft email and calendaring hosted service.
6,171 questions
Windows for business Windows Client for IT Pros Directory services Active Directory
Windows for business Windows Server User experience PowerShell
Microsoft Security Microsoft Entra Microsoft Entra ID
{count} votes

Accepted answer
  1. Rich Matheisen 47,901 Reputation points
    2024-08-29T18:36:25.8133333+00:00

    ObjectID is an AAD property. The Windows Active Directory uses an ObjectGUID property. for the same purpose.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.