Get-MgOrganization authentification problem

filoup 1 Reputation point
2022-04-26T13:12:17.823+00:00

HI,

My powershell script is connected to Graph API using a secretkey.

Modules Microsoft.Graph.Authentication and Microsoft.Graph.Identity.DirectoryManagement are imported.
use application permissions Organization.Read.All, Directory.Read.All, Organization.ReadWrite.All, Directory.ReadWrite.All

Get error "Get-MgOrganization : Authentication needed, call Connect-MgGraph" when running my script

Best regards

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

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 39,746 Reputation points
    2022-04-27T02:50:57+00:00

    Hi @filoup

    You need to use a service principal to connect to MgGraph:

    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.