You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Im trying to create a Daily update for all staff on their calendar entries which then will get sent to all management members.
In theory the script should loop through each user, view their daily entries and then open outlook and send me the updates.
But I keep getting these errors..
Get-MgUserCalendarView : Access is denied. Check credentials and try again.
I tried changing to "Users.ReadAll" , and pretty much all the rest as well
Connect-MgGraph -Scopes "Calendars.Read"
$timeZone = [System.TimeZoneInfo]::FindSystemTimeZoneById("New Zealand Standard Time")
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Im trying to create a Daily update for all staff on their calendar entries which then will get sent to all management members.
In theory the script should loop through each user, view their daily entries and then open outlook and send me the updates.
But I keep getting these errors..
Get-MgUserCalendarView : Access is denied. Check credentials and try again.
I tried changing to "Users.ReadAll" , and pretty much all the rest as well
Connect-MgGraph -Scopes "Calendars.Read"
$timeZone = [System.TimeZoneInfo]::FindSystemTimeZoneById("New Zealand Standard Time")
$startDate = [System.TimeZoneInfo]::ConvertTimeBySystemTimeZoneId((Get-Date), $timeZone.Id).Date
$endDate = $startDate.AddDays(1)
$users = Get-MgUser -Filter "accountEnabled eq true" -All
$emailBody = ""
foreach ($user in $users) {
$userId = $user.Id
$calendarEntries = Get-MgUserCalendarView -UserId $userId -StartDateTime $startDate -EndDateTime $endDate
}
if ($emailBody) {
Write-Output "Email body constructed successfully"
Write-Output $emailBody
} else {
Write-Output "No calendar entries found for any user"
}
Disconnect-MgGraph
Beta Was this translation helpful? Give feedback.
All reactions