How to Create Calendar Events Using Microsoft Graph API with PowerShell?

0
15
Asked By TechSavvy123 On

I'm trying to set up a test where I can add calendar events through the Microsoft Graph API using PowerShell. My goal is to grant my Global Admin user account permission to access its own calendar for testing purposes. I've been looking at the Microsoft documentation to start, but I have a few questions.

1. I'm using the Microsoft Graph Command Line Tools, but I can't find a way to add the Calendars.ReadWrite permission for user consent.

2. Should I create a new app registration just to grant user consent for Calendars.ReadWrite? If so, how do I, as a user, consent to that?

3. What's the process for running a PowerShell script under the context of the new app to add an event to my calendar?

Ultimately, I want to give my account permission to all mailbox calendars so I can add company-wide holidays to them. Is there an easier way to go about doing this?

4 Answers

Answered By CalendarExpert2023 On

It's fine to use an individual account for testing, but for automation, an app registration is the way to go. You can read more about app objects and service principals in the Microsoft docs.

TestingModeOn -

That makes sense. I'm still wrapping my head around it all, but it sounds like a solid plan.

Answered By GraphGuru88 On

You might want to dive deeper into the Microsoft Graph API and how permissions work. It can be a bit overwhelming initially, but a test account is a good way to experiment. Look into the permissions you need, especially the 'Calendars.ReadWrite.All' permission.

Answered By PowerShellPro22 On

You can connect with the command: Connect-MgGraph -scopes Calendars.ReadWrite.All. That should help set you up. Also, as a Global Admin, you might see an option to 'consent on behalf of your organization', but if you're only working on your calendar, you might skip that for now.

GlobalAdminGuy -

Thanks for the tip! I tried this and it really helped me get started. I managed to add events to my calendar using the command: Connect-MgGraph -Scopes Calendars.ReadWrite. I made sure not to check the organization consent box since I'm focusing solely on my own calendar.

PowerShellPro22 -

Glad to hear that worked for you! Once you hash out the basics, you can expand to other calendars as needed.

Answered By EventPlanner123 On

If you're looking to add holidays for everyone, remember that creating company-wide entries usually means using shared calendars or Teams. Have you considered that approach?

CalendarUser99 -

I totally get what you're saying, but I'm aiming to directly add holidays to individual user calendars. It's a lot simpler than what I dealt with back in the day.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.