Share via

Update-MGContact: Possible with unattended Access?

Gabe 26 Reputation points
Dec 21, 2021, 8:58 AM

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,628 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
23,993 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Cristian SPIRIDON 4,481 Reputation points
    Dec 21, 2021, 1:08 PM

    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,481 Reputation points
    Dec 22, 2021, 9:31 AM

    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,856 Reputation points
    Dec 22, 2021, 4:04 PM

    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

Your answer

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