How to connect to Microsoft Graph without prompt

Aase Nomad 246 Reputation points
2022-03-22T20:53:56.747+00:00

I'm trying to connect Microsoft Graph API in our remote desktop server using PowerShell and without the signin prompt/dialog so just wondering how can I do that?

how can I pass user credential?.

Connect-MgGraph

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,715 questions
{count} votes

Accepted answer
  1. CarlZhao-MSFT 37,296 Reputation points
    2022-03-25T03:05:50.783+00:00

    Hi @Aase Nomad

    Of course, you can use an unattended daemon, which requires connecting to MS graph using the application's client id and certificate name.

    Connect-MgGraph -ClientID YOUR_APP_ID -TenantId YOUR_TENANT_ID -CertificateName YOUR_CERT_SUBJECT  
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. CarlZhao-MSFT 37,296 Reputation points
    2022-03-23T03:19:24.99+00:00

    Hi @Aase Nomad

    This command uses the device code flow by default, and when you run this command it prompts you to go to the web page to log in with the device code. Next you just need to copy the device login link to the browser and enter the device code, after which you will be redirected to the user login page. Only after the user is logged in will you receive: "Welcome To Microsoft Graph!" message prompt.

    185923-image.png

    185922-image.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Vasil Michev 95,836 Reputation points MVP
    2022-03-23T07:15:25.337+00:00
    0 comments No comments