@@ -61,7 +61,7 @@ function ProcessCalendarSharingInviteLogs {
6161
6262 $logOutput = Export-MailboxDiagnosticLogs $Identity - ComponentName CalendarSharingInvite
6363 } catch {
64- Write-Error " Ignore above error, No CalendarSharingInvite logs found."
64+ Write-Warning " No CalendarSharingInvite logs found for [ $Identity ] ."
6565 }
6666
6767 # check if the output is empty
@@ -70,7 +70,6 @@ function ProcessCalendarSharingInviteLogs {
7070 return
7171 }
7272
73- $logLines = @ ()
7473 # Split the output into an array of lines
7574 $logLines = $logOutput.MailboxLog -split " `r`n "
7675
@@ -129,7 +128,7 @@ function ProcessCalendarSharingAcceptLogs {
129128 Write-Host " Collecting AcceptCalendarSharingInvite logs for [$Identity ] ..."
130129 $logOutput = Export-MailboxDiagnosticLogs $Identity - ComponentName AcceptCalendarSharingInvite
131130 } catch {
132- Write-Error " Ignore above error, No AcceptCalendarSharingInvite logs found."
131+ Write-Warning " No AcceptCalendarSharingInvite logs found for [ $Identity ] ."
133132 }
134133
135134 # check if the output is empty
@@ -138,7 +137,6 @@ function ProcessCalendarSharingAcceptLogs {
138137 return
139138 }
140139
141- $logLines = @ ()
142140 # Split the output into an array of lines
143141 $logLines = $logOutput.MailboxLog -split " `r`n "
144142
@@ -241,21 +239,16 @@ function ProcessInternetCalendarLogs {
241239 # $logOutput = Export-MailboxDiagnosticLogs $Identity -ComponentName AcceptCalendarSharingInvite -ErrorAction SilentlyContinue
242240 $logOutput = Export-MailboxDiagnosticLogs $Identity - ComponentName InternetCalendar
243241 } catch {
244- Write-Error " Ignore above error, No InternetCalendar logs found."
242+ Write-Warning " No InternetCalendar logs found for [ $Identity ] ."
245243 }
246244
247245 # check if the output is empty
248246 if ($null -eq $logOutput.MailboxLog ) {
249- Write-Host - ForegroundColor Green " ==========================================="
250- Write-Host - ForegroundColor Green " It is safe to ignore the big error above, it is just saying that there are no InternetCalendar logs."
251247 Write-Host - ForegroundColor Green " No InternetCalendar Logs found for [$Identity ]."
252248 Write-Host - ForegroundColor Green " User [$Identity ] is not receiving any Published Calendars."
253- Write-Host - ForegroundColor Green " ==========================================="
254249 return
255250 }
256251
257- $logLines = @ ()
258-
259252 # Split the output into an array of lines
260253 $logLines = $logOutput.MailboxLog -split " `r`n "
261254
@@ -303,14 +296,6 @@ function GetOwnerInformation {
303296 Write-Host - ForegroundColor DarkYellow " Key Owner Mailbox Information:"
304297 Write-Host - ForegroundColor DarkYellow " `t Running 'Get-Mailbox $Owner '"
305298 $script :OwnerMB = Get-Mailbox $Owner
306- # Write-Host "`t DisplayName:" $script:OwnerMB.DisplayName
307- # Write-Host "`t Database:" $script:OwnerMB.Database
308- # Write-Host "`t ServerName:" $script:OwnerMB.ServerName
309- # Write-Host "`t LitigationHoldEnabled:" $script:OwnerMB.LitigationHoldEnabled
310- # Write-Host "`t CalendarVersionStoreDisabled:" $script:OwnerMB.CalendarVersionStoreDisabled
311- # Write-Host "`t CalendarRepairDisabled:" $script:OwnerMB.CalendarRepairDisabled
312- # Write-Host "`t RecipientTypeDetails:" $script:OwnerMB.RecipientTypeDetails
313- # Write-Host "`t RecipientType:" $script:OwnerMB.RecipientType
314299
315300 if (-not $script :OwnerMB ) {
316301 Write-Host - ForegroundColor Yellow " Could not find Owner Mailbox [$Owner ]."
@@ -337,7 +322,7 @@ function GetOwnerInformation {
337322 $OwnerCalendarStats = Get-MailboxFolderStatistics - Identity $Owner - FolderScope Calendar
338323 $OwnerCalendarName = ($OwnerCalendarStats | Where-Object FolderType -EQ " Calendar" ).Name
339324
340- $OwnerCalendarStats | Format-Table - a FolderPath, ItemsInFolder , FolderAndSubfolderSize
325+ $OwnerCalendarStats | Format-Table - a FolderPath, VisibleItemsInFolder , FolderAndSubfolderSize
341326
342327 Write-Host - ForegroundColor DarkYellow " Owner Calendar Permissions:"
343328 Write-Host - ForegroundColor DarkYellow " `t Running 'Get-MailboxFolderPermission " ${Owner} :\$OwnerCalendarName " | Format-Table -a User, AccessRights, SharingPermissionFlags'"
@@ -351,7 +336,7 @@ function GetOwnerInformation {
351336 }
352337
353338 # Warn if the Calendar count is greater than 100,000 items
354- if ([int ]$OwnerCalendarStats [0 ].ItemsInFolder -gt 100000 ) {
339+ if ([int ]$OwnerCalendarStats [0 ].VisibleItemsInFolder -gt 100000 ) {
355340 Write-Host - ForegroundColor Yellow " Warning: Owner Calendar has more than 100,000 items. This can impact calendar performance."
356341 Write-Host - ForegroundColor Yellow " `t Consider archiving old calendar items."
357342 }
@@ -375,6 +360,7 @@ function GetOwnerInformation {
375360 $script :OwnerPublished = $false
376361 }
377362
363+ Write-Host - ForegroundColor DarkYellow " `t ExtendedFolderFlags: $ ( $OwnerCalendarFolder.ExtendedFolderFlags ) "
378364 if ($OwnerCalendarFolder.ExtendedFolderFlags.Contains (" SharedOut" )) {
379365 Write-Host - ForegroundColor Green " Owner Calendar is Shared Out using Modern Sharing."
380366 $script :OwnerModernSharing = $true
@@ -383,15 +369,6 @@ function GetOwnerInformation {
383369 $script :OwnerModernSharing = $false
384370 }
385371
386- Write-Host - ForegroundColor DarkYellow " `t Running 'Get-MailboxCalendarFolder -Identity " ${Owner} :\$OwnerCalendarName " '"
387- $CalFolderProps = Get-MailboxCalendarFolder - Identity " ${Owner} :\$OwnerCalendarName "
388- Write-Host - ForegroundColor DarkYellow " `t ExtendedFolderFlags: $ ( $CalFolderProps.ExtendedFolderFlags ) "
389- if ($CalFolderProps.ExtendedFolderFlags -like " *SharedOut*" ) {
390- Write-Host - ForegroundColor Green " `t Calendar is Shared Out using Modern Sharing."
391- } else {
392- Write-Host - ForegroundColor Red " `t Calendar is not Shared Out using Modern Sharing."
393- }
394-
395372 # cSpell:ignore Sharees
396373 if (Get-Command - Name Get-CalendarActiveSharingInformation - ErrorAction SilentlyContinue) {
397374 Write-Host - ForegroundColor DarkYellow " `t Running 'Get-CalendarActiveSharingInformation -Identity " ${Owner} :\$OwnerCalendarName " '"
@@ -455,7 +432,7 @@ function GetReceiverInformation {
455432 Write-Host - ForegroundColor Cyan " Receiver Calendar Folders (look for a copy of [$OwnerCalendarName ] Calendar):"
456433 Write-Host - ForegroundColor Cyan " Running: 'Get-MailboxFolderStatistics -Identity $Receiver -FolderScope Calendar'"
457434 $CalStats = Get-MailboxFolderStatistics - Identity $Receiver - FolderScope Calendar
458- $CalStats | Format-Table - a FolderPath, ItemsInFolder , FolderAndSubfolderSize
435+ $CalStats | Format-Table - a FolderPath, VisibleItemsInFolder , FolderAndSubfolderSize
459436 $ReceiverCalendarName = ($CalStats | Where-Object FolderType -EQ " Calendar" ).Name
460437
461438 # Warning if there are multiple copies of the Owner Calendar in the Receiver Mailbox.
@@ -464,7 +441,7 @@ function GetReceiverInformation {
464441 }
465442
466443 # Warning if the Receivers copy of the Calendar name is the default "Calendar".
467- if (($CalStats.name -like " Cal *" ).count -gt 1 ) {
444+ if (($CalStats.name -like " Calendar *" ).count -gt 1 ) {
468445 Write-Host - ForegroundColor Yellow " Warning: Receiver might have multiple Calendars named 'Calendar'."
469446 Write-Host - ForegroundColor Yellow " Warning: This can cause confusion with which calendar is being referenced."
470447 }
@@ -475,14 +452,14 @@ function GetReceiverInformation {
475452 }
476453
477454 # Note $Owner has a * at the end in case we have had multiple setup for the same user, they will be appended with a " 1", etc.
478- if (($CalStats | Where-Object Name -Like $Owner * ) -or ($CalStats | Where-Object Name -Like " $ ( $script :OwnerMB.DisplayName ) *" )) {
455+ if (($CalStats | Where-Object Name -Like " $Owner *" ) -or ($CalStats | Where-Object Name -Like " $ ( $script :OwnerMB.DisplayName ) *" )) {
479456 Write-Host - ForegroundColor Green " Looks like we might have found a copy of the Owner Calendar in the Receiver Mailbox."
480457 Write-Host - ForegroundColor Green " This is a good indication the there is a Modern Sharing Relationship between these users."
481458 Write-Host - ForegroundColor Green " If the clients use the Modern Sharing or not is a up to the client."
482459 $script :ModernSharing = $true
483460
484- $CalStats | Where-Object Name -Like $Owner * | Format-Table - a FolderPath, ItemsInFolder , FolderAndSubfolderSize
485- if (($CalStats | Where-Object Name -Like $Owner * ).count -gt 1 ) {
461+ $CalStats | Where-Object Name -Like " $Owner *" | Format-Table - a FolderPath, VisibleItemsInFolder , FolderAndSubfolderSize
462+ if (($CalStats | Where-Object Name -Like " $Owner *" ).count -gt 1 ) {
486463 Write-Host - ForegroundColor Yellow " Warning: Might have found more than one copy of the Owner Calendar in the Receiver Mailbox."
487464 }
488465 } else {
@@ -517,19 +494,6 @@ function GetReceiverInformation {
517494 Write-Host " Consider upgrading these to the new model."
518495 $ReceiverCalEntries | Where-Object SharingModelType -Like Old | Format-Table CalendarGroupName, CalendarName, OwnerEmailAddress, SharingModelType, IsOrphanedEntry
519496 }
520-
521- # need to check if Get-CalendarValidationResult in the PS Workspace
522- if ((Get-Command - Name Get-CalendarValidationResult - ErrorAction SilentlyContinue) -and
523- $null -ne $ReceiverCalEntries ) {
524- $ewsId_del = $ReceiverCalEntries [0 ].LocalFolderId
525- Write-Host " Trying to run cmdlet: Get-CalendarValidationResult -Version V2 -Identity $Receiver -SourceCalendarId $ewsId_del -TargetUserId $Owner -IncludeAnalysis 1 -OnlyReportErrors 1 | FT -a GlobalObjectId, EventValidationResult "
526- try {
527- $ValidationResults = Get-CalendarValidationResult - Version V2 - Identity $Receiver - SourceCalendarId $ewsId_del - TargetUserId $Owner - IncludeAnalysis 1 - OnlyReportErrors 1
528- $ValidationResults | Format-List UserPrimarySMTPAddress, Subject, GlobalObjectId, EventValidationResult, EventComparisonResult
529- } catch {
530- Write-Error " Failed to run Get-CalendarValidationResult: $_ "
531- }
532- }
533497 }
534498
535499 # Output key Modern Sharing information
@@ -571,8 +535,8 @@ function GetReceiverInformation {
571535}
572536
573537# Main
574- $script :ModernSharing
575- $script :SharingType
538+ $script :ModernSharing = $false
539+ $script :SharingType = $null
576540GetOwnerInformation - Owner $Owner
577541GetReceiverInformation - Receiver $Receiver
578542
0 commit comments