Assign Calendar Privileges with Powershell
Im trying to assign Calendar Permissions to Owner and Member, Owner should have read&write while members only read.
This is the code i came up with. the error i got was the following:
Specified method is not supported.
Status: 400 (BadRequest)
ErrorCode: ErrorNotSupported
Thank you for your help.
$groupId`` = "your-group-id"
$calendarId`` = "calendar"
$owners`` = Get-MgGroupOwner -GroupId $groupId
$members`` = Get-MgGroupMember -GroupId $groupId
foreach`` ($owner in $owners) {
$ownerId`` = $owner.Id
New-MgUserCalendarPermission`` -UserId $ownerId -CalendarId $calendarId -Role "write"
}
foreach`` ($member in $members) {
$memberId`` = $member.Id
New-MgUserCalendarPermission`` -UserId $memberId -CalendarId $calendarId -Role "read"
}
$groupId
$calendarId
$owners
$members
foreach
$ownerId
New-MgUserCalendarPermission
}
foreach
$memberId
New-MgUserCalendarPermission
}