How to Set Up Calendar Permissions for Multiple Users in Microsoft Graph?

0
11
Asked By LearningCodeNinja99 On

I'm diving into Microsoft Graph and trying to grant write access to six users so they can modify each other's primary calendars. I've come across an error, specifically: "Cannot process argument transformation on parameter 'CalendarId'. Cannot convert value to type System.String." I've attached a snippet of my code, where I'm looping through the users and using the Get-MgUserCalendar and Get-MgUserCalendarPermission commands. Any suggestions on what might be going wrong?

4 Answers

Answered By CloudGuru91 On

Since you're using M365 accounts, consider managing these permissions directly through the MS 365 admin portal or the Exchange Online module for a more straightforward process. Leveraging Microsoft Graph can be tricky at first, especially with permission handling.

Answered By TechSavvyChick On

Your error indicates that `$primaryCalendar.id` isn't a string. This can happen if there are multiple calendars returned for a user. Check the contents of `$primaryCalendar` to see if it’s returning more than one calendar and ensure you're pointing to the correct one.

Answered By DebugMaster007 On

I noticed you set `$primaryCalendar` as an array first and then immediately overwrite it with a single calendar. This could lead to confusion. Since you're targeting one user's primary calendar, you should just assign it directly and avoid the array initialization. Also, make sure that `$primaryCalendar.id` is indeed a single string and not multiple values.

Answered By CodeSlinger42 On

It looks like you're trying to fetch the user calendar permission but the CalendarId might not be formatted correctly as a string. Try using `$existingPerm = Get-MgUserCalendarPermission -UserId $targetUser -CalendarId "$($primaryCalendar.id)"` to force it to convert into a string. You might also want to print out what `$primaryCalendar.id` returns just to be sure it's what you expect.

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.