Get the information of the logged on user in O365 with GRAPH and Powershell.

[ADM] Thomas Jadot (GCLOUD) 21 Reputation points
2024-02-19T12:00:57.0266667+00:00

Hello, I want to get these properties for automatically create the signature in Outlook. I already created the GRAPH application with user.read permission and a client secret. I can get the token via the module MSAL-PS but I receive an authentication popup where I have only to choose the user nothing else (no password). But I'm already logged on with this user. Is it possible to avoid this popup? Pass directly the active user in the request? I'm logged on on a Windows 11 computer azure AD joined. I get the active token with $MSALToken = Get-MsalToken -ClientId $clientId -TenantId $TenantId -Scopes $scope $AuthHeader = @{'Authorization' = $MSALToken.CreateAuthorizationHeader()} I determine the attributes I need with $URI = 'https://graph.microsoft.com/v1.0/me?$select=givenname,surname,department,JobTitle,businessPhones,mobilePhone,preferredLanguage,displayName,mail,OfficeLocation' And I invoke my request with Invoke-RestMethod -Uri $URI -Headers $AuthHeader -Method Get

Windows for business | Windows Server | User experience | PowerShell
Microsoft Security | Microsoft Graph
0 comments No comments

1 answer

Sort by: Oldest
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.

    5 deleted comments

    Comments have been turned off. Learn more

Your answer

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