Share via

Get-MgOrganization authentification problem

Anonymous
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 Security | Microsoft Graph

1 answer

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

    Hi @Anonymous

    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.

    Was this answer helpful?


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.