Update-MGContact: Possible with unattended Access?

Gabe 11 Reputation points
2021-12-21T08:58:03.157+00:00

Hello Everyone

I am trying to set up a Powershell-Script as a scheduled task that automatically updates Contacts in the Azure Database unattended, without having to add a Password to the Script. I unfortunately receive an Error-Message, despite having the necessary rights for it (im Using an AppOnly Authentication Method for it with a self signed certificate):
![![159235-grafik.png]1]1
The error message is "Insufficient Privileges to complete the operation"

Now, someone from this forum already helped me by telling me that "Update-MGContact" is ReadOnly, but is there a way to update a Contact with an Unattended connection?

Thank you for your help.

Kind regards,

Gabe

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,387 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,640 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Cristian SPIRIDON 4,471 Reputation points
    2021-12-21T13:08:09.147+00:00

    Hi,

    Using Microsoft.Graph scripts with a Service account should be possible. Maybe you did not grant all necesarry permisions to the App Registration account.

    More info at:
    https://tech.nicolonsky.ch/exploring-the-new-microsoft-graph-powershell-modules/

    Hope this helps!


  2. Cristian SPIRIDON 4,471 Reputation points
    2021-12-22T09:31:55.617+00:00

    Hi,

    I see that you have permissions.
    What I found strange is that there are both application and delegated permissions. I would expect only application. Delegated means that you action on behalf of a user which is not the case according to your description.

    I would add directory.readwrite.all permision at application level and see if that fix the issue.

    Hope this helps!


  3. Limitless Technology 39,391 Reputation points
    2021-12-22T16:04:27.06+00:00

    Hello @Gabe

    I would like to recommend you the next official articles, that can help you to review the permissions and account types for Microsoft Graph:

    Permissions:
    https://learn.microsoft.com/en-us/graph/permissions-reference

    Application vs Seivice principals:
    https://learn.microsoft.com/en-us/azure/active-directory/develop/app-objects-and-service-principals

    Hope this helps with your query,

    ---------
    --If the reply is helpful, please Upvote and Accept as answer--

    0 comments No comments