From 48420007f8ded82146c7bf8146673be2be949126 Mon Sep 17 00:00:00 2001 From: Shane Ferrell Date: Thu, 11 Jul 2024 15:22:21 -0700 Subject: [PATCH 1/2] Fix PS errors caused by ImportExcel not be installed, minor tweaks fix client names License Add Sensitivity Use Get-Recipient where we can instead of Get-MB Fix Room MB detection when no PII Formatting --- Calendar/CalLogHelpers/CalLogCSVFunctions.ps1 | 1 + .../CalLogHelpers/CalLogExportFunctions.ps1 | 207 ----------------- .../CalLogHelpers/CalLogInfoFunctions.ps1 | 14 +- .../CalLogHelpers/ExcelModuleInstaller.ps1 | 3 +- .../CalLogHelpers/ExportToExcelFunctions.ps1 | 212 ++++++++++++++++++ Calendar/CalLogHelpers/Invoke-GetCalLogs.ps1 | 1 + Calendar/CalLogHelpers/Invoke-GetMailbox.ps1 | 81 ++++--- .../ShortClientNameFunctions.ps1 | 5 + Calendar/CalLogHelpers/TimelineFunctions.ps1 | 5 + Calendar/Check-SharingStatus.ps1 | 4 +- .../Get-CalendarDiagnosticObjectsSummary.ps1 | 10 +- 11 files changed, 292 insertions(+), 251 deletions(-) create mode 100644 Calendar/CalLogHelpers/ExportToExcelFunctions.ps1 diff --git a/Calendar/CalLogHelpers/CalLogCSVFunctions.ps1 b/Calendar/CalLogHelpers/CalLogCSVFunctions.ps1 index b5bbd0282d..10b10d8e6b 100644 --- a/Calendar/CalLogHelpers/CalLogCSVFunctions.ps1 +++ b/Calendar/CalLogHelpers/CalLogCSVFunctions.ps1 @@ -19,6 +19,7 @@ $script:CalendarItemTypes = @{ 'IPM.Schedule.Meeting.Resp.Neg' = "Resp.Neg" 'IPM.Schedule.Meeting.Resp.Tent' = "Resp.Tent" 'IPM.Schedule.Meeting.Resp.Pos' = "Resp.Pos" + '(Occurrence Deleted)' = "Exception.Deleted" } # =================================================================================================== diff --git a/Calendar/CalLogHelpers/CalLogExportFunctions.ps1 b/Calendar/CalLogHelpers/CalLogExportFunctions.ps1 index bcf74bc913..469d451527 100644 --- a/Calendar/CalLogHelpers/CalLogExportFunctions.ps1 +++ b/Calendar/CalLogHelpers/CalLogExportFunctions.ps1 @@ -59,22 +59,6 @@ function Export-CalLogCSV { $script:GCDO | Export-Csv -Path $FilenameRaw -NoTypeInformation -Encoding UTF8 } -# Export to Excel -function Export-CalLogExcel { - Write-Host -ForegroundColor Cyan "Exporting Enhanced CalLogs to Excel Tab [$ShortId]..." - $ExcelParamsArray = GetExcelParams -path $FileName -tabName $ShortId - - $excel = $GCDOResults | Export-Excel @ExcelParamsArray -PassThru - - FormatHeader ($excel) - - Export-Excel -ExcelPackage $excel -WorksheetName $ShortId -MoveToStart - - # Export Raw Logs for Developer Analysis - Write-Host -ForegroundColor Cyan "Exporting Raw CalLogs to Excel Tab [$($ShortId + "_Raw")]..." - $script:GCDO | Export-Excel -Path $FileName -WorksheetName $($ShortId + "_Raw") -AutoFilter -FreezeTopRow -BoldTopRow -MoveToEnd -} - function Export-Timeline { Write-Verbose "Export to Excel is : $ExportToExcel" @@ -88,194 +72,3 @@ function Export-Timeline { $script:TimeLineOutput | Export-Csv -Path $script:TimeLineFilename -NoTypeInformation -Encoding UTF8 -Append } } - -function Export-TimelineExcel { - Write-Host -ForegroundColor Cyan "Exporting Timeline to Excel..." - $script:TimeLineOutput | Export-Excel -Path $FileName -WorksheetName $($ShortId + "_TimeLine") -Title "Timeline for $Identity" -AutoSize -FreezeTopRow -BoldTopRow -} - -function GetExcelParams($path, $tabName) { - if ($script:IsOrganizer) { - $TableStyle = "Light10" # Orange for Organizer - $TitleExtra = ", Organizer" - } elseif ($script:IsRoomMB) { - Write-Host -ForegroundColor green "Room Mailbox Detected" - $TableStyle = "Light11" # Green for Room Mailbox - $TitleExtra = ", Resource" - } else { - $TableStyle = "Light12" # Light Blue for normal - # Dark Blue for Delegates (once we can determine this) - } - - return @{ - Path = $path - FreezeTopRow = $true - # BoldTopRow = $true - Verbose = $false - TableStyle = $TableStyle - WorksheetName = $tabName - TableName = $tabName - FreezeTopRowFirstColumn = $true - AutoFilter = $true - AutoNameRange = $true - Append = $true - Title = "Enhanced Calendar Logs for $Identity" + $TitleExtra + " for MeetingID [$($script:GCDO[0].CleanGlobalObjectId)]." - TitleSize = 14 - ConditionalText = $ConditionalFormatting - } -} - -# Need better way of tagging cells than the Range. Every time one is updated, you need to update all the ones after it. -$ConditionalFormatting = $( - # Client, ShortClientInfoString and LogClientInfoString - New-ConditionalText "Outlook" -ConditionalTextColor Green -BackgroundColor $null - New-ConditionalText "OWA" -ConditionalTextColor DarkGreen -BackgroundColor $null - New-ConditionalText "Transport" -ConditionalTextColor Blue -BackgroundColor $null - New-ConditionalText "Repair" -ConditionalTextColor DarkRed -BackgroundColor LightPink - New-ConditionalText "Other ?BA" -ConditionalTextColor Orange -BackgroundColor $null - New-ConditionalText "Other REST" -ConditionalTextColor DarkRed -BackgroundColor $null - New-ConditionalText "ResourceBookingAssistant" -ConditionalTextColor Blue -BackgroundColor $null - - #LogType - New-ConditionalText -Range "C3:C9999" -ConditionalType ContainsText -Text "Ignorable" -ConditionalTextColor DarkRed -BackgroundColor $null - New-ConditionalText -Range "C:C" -ConditionalType ContainsText -Text "Cleanup" -ConditionalTextColor DarkRed -BackgroundColor $null - New-ConditionalText -Range "C:C" -ConditionalType ContainsText -Text "Sharing" -ConditionalTextColor Blue -BackgroundColor $null - - # TriggerAction - New-ConditionalText -Range "G:G" -ConditionalType ContainsText -Text "Create" -ConditionalTextColor Green -BackgroundColor $null - New-ConditionalText -Range "G:G" -ConditionalType ContainsText -Text "Delete" -ConditionalTextColor Red -BackgroundColor $null - # ItemClass - New-ConditionalText -Range "H:H" -ConditionalType ContainsText -Text "IPM.Appointment" -ConditionalTextColor Blue -BackgroundColor $null - New-ConditionalText -Range "H:H" -ConditionalType ContainsText -Text "Canceled" -ConditionalTextColor Black -BackgroundColor Orange - New-ConditionalText -Range "H:H" -ConditionalType ContainsText -Text ".Request" -ConditionalTextColor DarkGreen -BackgroundColor $null - New-ConditionalText -Range "H:H" -ConditionalType ContainsText -Text ".Resp." -ConditionalTextColor Orange -BackgroundColor $null - New-ConditionalText -Range "H:H" -ConditionalType ContainsText -Text "IPM.OLE.CLASS" -ConditionalTextColor Plum -BackgroundColor $null - - #FreeBusyStatus - New-ConditionalText -Range "L3:L9999" -ConditionalType ContainsText -Text "Free" -ConditionalTextColor Red -BackgroundColor $null - New-ConditionalText -Range "L3:L9999" -ConditionalType ContainsText -Text "Tentative" -ConditionalTextColor Orange -BackgroundColor $null - New-ConditionalText -Range "L3:L9999" -ConditionalType ContainsText -Text "Busy" -ConditionalTextColor Green -BackgroundColor $null - - #Shared Calendar information - New-ConditionalText -Range "Q3:Q9999" -ConditionalType NotEqual -Text "Not Shared" -ConditionalTextColor Blue -BackgroundColor $null - New-ConditionalText -Range "R:R" -ConditionalType ContainsText -Text "TRUE" -ConditionalTextColor Blue -BackgroundColor $null - New-ConditionalText -Range "S:S" -ConditionalType NotEqual -Text "NotFound" -ConditionalTextColor Blue -BackgroundColor $null - - #MeetingRequestType - New-ConditionalText -Range "V:V" -ConditionalType ContainsText -Text "Outdated" -ConditionalTextColor DarkRed -BackgroundColor LightPink - - #AppointmentAuxiliaryFlags - New-ConditionalText -Range "AE3:AE9999" -ConditionalType ContainsText -Text "Copy" -ConditionalTextColor DarkRed -BackgroundColor LightPink - - #ResponseType - New-ConditionalText -Range "AI3:AI9999" -ConditionalType ContainsText -Text "Organizer" -ConditionalTextColor Orange -BackgroundColor $null - -) - -function FormatHeader { - param( - [object] $excel - ) - $sheet = $excel.Workbook.Worksheets[$ShortId] - $HeaderRow = 2 - $n = 0 - - # Static List of Columns for now... - $sheet.Column(++$n) | Set-ExcelRange -Width 6 -HorizontalAlignment center # LogRow - Set-CellComment -Text "This is the Enhanced Calendar Logs for [$Identity] for MeetingID `n [$($script:GCDO[0].CleanGlobalObjectId)]." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 20 -NumberFormat "m/d/yyyy h:mm:ss" -HorizontalAlignment center #LogTimestamp - Set-CellComment -Text "LogTimestamp: Time when the change was recorded in the CalLogs. This and all Times are in UTC." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 11 -HorizontalAlignment center # LogType - Set-CellComment -Text "LogType: Can this Log be safely ignored?" -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 20 -HorizontalAlignment Left # SubjectProperty - Set-CellComment -Text "SubjectProperty: The Subject of the Meeting." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 20 -HorizontalAlignment Left # Client - Set-CellComment -Text "Client: The 'friendly' Client name of the client that made the change." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 5 -HorizontalAlignment Left # LogClientInfoString - Set-CellComment -Text "LogClientInfoString: Full Client Info String of client that made the change." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 12 -HorizontalAlignment Center # TriggerAction - Set-CellComment -Text "TriggerAction: The action that caused the change." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 18 -HorizontalAlignment Left # ItemClass - Set-CellComment -Text "ItemClass: The Class of the Calendar Item" -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment center # Seq:Exp:ItemVersion - Set-CellComment -Text "Seq:Exp:ItemVersion: The Sequence Version, the Exception Version, and the Item Version. Each type of item has its own count." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 20 -HorizontalAlignment Left # Organizer - Set-CellComment -Text "Organizer: The Organizer of the Calendar Item." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 20 -HorizontalAlignment Left # From - Set-CellComment -Text "From: The SMTP address of the Organizer of the Calendar Item." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 12 -HorizontalAlignment center # FreeBusyStatus - Set-CellComment -Text "FreeBusyStatus: The FreeBusy Status of the Calendar Item." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 20 -HorizontalAlignment Left # ResponsibleUser - Set-CellComment -Text "ResponsibleUser: The Responsible User of the change." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 20 -HorizontalAlignment Left # Sender - Set-CellComment -Text "Sender: The Sender of the change." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 16 -HorizontalAlignment Left # LogFolder - Set-CellComment -Text "LogFolder: The Log Folder that the CalLog was in." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 16 -HorizontalAlignment Left # OriginalLogFolder - Set-CellComment -Text "OriginalLogFolder: The Original Log Folder that the item was in / delivered to." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 15 -HorizontalAlignment Right # SharedFolderName - Set-CellComment -Text "SharedFolderName: Was this from a Modern Sharing, and if so what Folder." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment center # IsFromSharedCalendar - Set-CellComment -Text "IsFromSharedCalendar: Is this CalLog from a Modern Sharing relationship?" -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 20 -HorizontalAlignment Left # ExternalSharingMasterId - Set-CellComment -Text "ExternalSharingMasterId: If this is not [NotFound], then it is from a Modern Sharing relationship." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment Left # ReceivedBy - Set-CellComment -Text "ReceivedBy: The Receiver of the Calendar Item. Should always be the owner of the Mailbox." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment Left # ReceivedRepresenting - Set-CellComment -Text "ReceivedRepresenting: Who the item was Received for, of then the Delegate." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment center # MeetingRequestType - Set-CellComment -Text "MeetingRequestType: The Meeting Request Type of the Meeting." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 20 -NumberFormat "m/d/yyyy h:mm:ss" -HorizontalAlignment center # StartTime - Set-CellComment -Text "StartTime: The Start Time of the Meeting. This and all Times are in UTC." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 20 -NumberFormat "m/d/yyyy h:mm:ss" -HorizontalAlignment center # EndTime - Set-CellComment -Text "EndTime: The End Time of the Meeting. This and all Times are in UTC." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 17 -NumberFormat "m/d/yyyy h:mm:ss" -HorizontalAlignment Left # OriginalStartDate - Set-CellComment -Text "OriginalStartDate: The Original Start Date of the Meeting." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment Left # TimeZone - Set-CellComment -Text "TimeZone: The Time Zone of the Meeting." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment Left # Location - Set-CellComment -Text "Location: The Location of the Meeting." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment center # CalendarItemType - Set-CellComment -Text "CalendarItemType: The Calendar Item Type of the Meeting." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment center # IsException - Set-CellComment -Text "IsException: Is this an Exception?" -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 20 -HorizontalAlignment Left # RecurrencePattern - Set-CellComment -Text "RecurrencePattern: The Recurrence Pattern of the Meeting." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 30 -HorizontalAlignment Center # AppointmentAuxiliaryFlags - Set-CellComment -Text "AppointmentAuxiliaryFlags: The Appointment Auxiliary Flags of the Meeting." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 30 -HorizontalAlignment Left # DisplayAttendeesAll - Set-CellComment -Text "DisplayAttendeesAll: List of the Attendees of the Meeting." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment center # AttendeeCount - Set-CellComment -Text "AttendeeCount: The Attendee Count." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 20 -HorizontalAlignment Left # AppointmentState - Set-CellComment -Text "AppointmentState: The Appointment State of the Meeting." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment center # ResponseType - Set-CellComment -Text "ResponseType: The Response Type of the Meeting." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 20 -HorizontalAlignment center # ClientIntent - Set-CellComment -Text "ClientIntent: The Client Intent of the Meeting." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment center # AppointmentRecurring - Set-CellComment -Text "AppointmentRecurring: Is this a Recurring Meeting?" -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment center # HasAttachment - Set-CellComment -Text "HasAttachment: Does this Meeting have an Attachment?" -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment center # IsCancelled - Set-CellComment -Text "IsCancelled: Is this Meeting Cancelled?" -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment center # IsAllDayEvent - Set-CellComment -Text "IsAllDayEvent: Is this an All Day Event?" -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment center # IsSeriesCancelled - Set-CellComment -Text "IsSeriesCancelled: Is this a Series Cancelled Meeting?" -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 30 -HorizontalAlignment Left # SendMeetingMessagesDiagnostics - Set-CellComment -Text "SendMeetingMessagesDiagnostics: Compound Property to describe why meeting was or was not sent to everyone." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 50 -HorizontalAlignment Left # AttendeeCollection - Set-CellComment -Text "AttendeeCollection: The Attendee Collection of the Meeting, use -TrackingLogs to get values." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 40 -HorizontalAlignment Center # CalendarLogRequestId - Set-CellComment -Text "CalendarLogRequestId: The Calendar Log Request ID of the Meeting." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - $sheet.Column(++$n) | Set-ExcelRange -Width 120 -HorizontalAlignment Left # CleanGlobalObjectId - Set-CellComment -Text "CleanGlobalObjectId: The Clean Global Object ID of the Meeting." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet - - # Update header rows after all the others have been set. - # Title Row - $sheet.Row(1) | Set-ExcelRange -HorizontalAlignment Left - - # Set the Header row to be bold and left aligned - $sheet.Row($HeaderRow) | Set-ExcelRange -Bold -HorizontalAlignment Left -} diff --git a/Calendar/CalLogHelpers/CalLogInfoFunctions.ps1 b/Calendar/CalLogHelpers/CalLogInfoFunctions.ps1 index 90d36ce7ef..fccfcd6897 100644 --- a/Calendar/CalLogHelpers/CalLogInfoFunctions.ps1 +++ b/Calendar/CalLogHelpers/CalLogInfoFunctions.ps1 @@ -32,24 +32,22 @@ function SetIsRoom { param( $CalLogs ) - [bool] $IsRoom = $false + # See if we have already determined this is a Room MB. if ($script:Rooms -contains $Identity) { - $IsRoom = $true - return $IsRoom + return $true } # Simple logic is if RBA is running on the MB, it is a Room MB, otherwise it is not. foreach ($CalLog in $CalLogs) { - Write-Verbose "Checking if this is a Room Mailbox. [$($CalLog.ItemType)] [$($CalLog.ExternalSharingMasterId)] [$($CalLog.LogClientInfoString)]" - if ($CalLog.ItemType -eq "IPM.Appointment" -and + Write-Verbose "Checking if this is a Room Mailbox. [$($CalLog.ItemClass)] [$($CalLog.ExternalSharingMasterId)] [$($CalLog.LogClientInfoString)]" + if ($CalLog.ItemClass -eq "IPM.Appointment" -and $CalLog.ExternalSharingMasterId -eq "NotFound" -and $CalLog.LogClientInfoString -like "*ResourceBookingAssistant*" ) { - $IsRoom = $true - return $IsRoom + return $true } } - return $IsRoom + return $false } <# diff --git a/Calendar/CalLogHelpers/ExcelModuleInstaller.ps1 b/Calendar/CalLogHelpers/ExcelModuleInstaller.ps1 index bac893f8af..3f542ee0c6 100644 --- a/Calendar/CalLogHelpers/ExcelModuleInstaller.ps1 +++ b/Calendar/CalLogHelpers/ExcelModuleInstaller.ps1 @@ -2,7 +2,8 @@ # Licensed under the MIT License. # =================================================================================================== -# Excel Functions +# ImportExcel Functions +# see https://github.com/dfinke/ImportExcel for information on the module. # =================================================================================================== function CheckExcelModuleInstalled { [CmdletBinding(SupportsShouldProcess=$true)] diff --git a/Calendar/CalLogHelpers/ExportToExcelFunctions.ps1 b/Calendar/CalLogHelpers/ExportToExcelFunctions.ps1 new file mode 100644 index 0000000000..b7153135a1 --- /dev/null +++ b/Calendar/CalLogHelpers/ExportToExcelFunctions.ps1 @@ -0,0 +1,212 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +# Export to Excel +function Export-CalLogExcel { + Write-Host -ForegroundColor Cyan "Exporting Enhanced CalLogs to Excel Tab [$ShortId]..." + $ExcelParamsArray = GetExcelParams -path $FileName -tabName $ShortId + + $excel = $GCDOResults | Export-Excel @ExcelParamsArray -PassThru + + FormatHeader ($excel) + + Export-Excel -ExcelPackage $excel -WorksheetName $ShortId -MoveToStart + + # Export Raw Logs for Developer Analysis + Write-Host -ForegroundColor Cyan "Exporting Raw CalLogs to Excel Tab [$($ShortId + "_Raw")]..." + $script:GCDO | Export-Excel -Path $FileName -WorksheetName $($ShortId + "_Raw") -AutoFilter -FreezeTopRow -BoldTopRow -MoveToEnd +} + +function Export-TimelineExcel { + Write-Host -ForegroundColor Cyan "Exporting Timeline to Excel..." + $script:TimeLineOutput | Export-Excel -Path $FileName -WorksheetName $($ShortId + "_TimeLine") -Title "Timeline for $Identity" -AutoSize -FreezeTopRow -BoldTopRow +} + +function GetExcelParams($path, $tabName) { + if ($script:IsOrganizer) { + $TableStyle = "Light10" # Orange for Organizer + $TitleExtra = ", Organizer" + } elseif ($script:IsRoomMB) { + Write-Host -ForegroundColor green "Room Mailbox Detected" + $TableStyle = "Light11" # Green for Room Mailbox + $TitleExtra = ", Resource" + } else { + $TableStyle = "Light12" # Light Blue for normal + # Dark Blue for Delegates (once we can determine this) + } + + if ($script:CalLogsDisabled) { + $TitleExtra += ", WARNING: CalLogs are Turned Off for $Identity! This will be a incomplete story" + } + + return @{ + Path = $path + FreezeTopRow = $true + # BoldTopRow = $true + Verbose = $false + TableStyle = $TableStyle + WorksheetName = $tabName + TableName = $tabName + FreezeTopRowFirstColumn = $true + AutoFilter = $true + AutoNameRange = $true + Append = $true + Title = "Enhanced Calendar Logs for $Identity" + $TitleExtra + " for MeetingID [$($script:GCDO[0].CleanGlobalObjectId)]." + TitleSize = 14 + ConditionalText = $ConditionalFormatting + } +} + +# Need better way of tagging cells than the Range. Every time one is updated, you need to update all the ones after it. +$ConditionalFormatting = $( + # Client, ShortClientInfoString and LogClientInfoString + New-ConditionalText "Outlook" -ConditionalTextColor Green -BackgroundColor $null + New-ConditionalText "OWA" -ConditionalTextColor DarkGreen -BackgroundColor $null + New-ConditionalText "Transport" -ConditionalTextColor Blue -BackgroundColor $null + New-ConditionalText "Repair" -ConditionalTextColor DarkRed -BackgroundColor LightPink + New-ConditionalText "Other ?BA" -ConditionalTextColor Orange -BackgroundColor $null + New-ConditionalText "Other REST" -ConditionalTextColor DarkRed -BackgroundColor $null + New-ConditionalText "ResourceBookingAssistant" -ConditionalTextColor Blue -BackgroundColor $null + + #LogType + New-ConditionalText -Range "C3:C9999" -ConditionalType ContainsText -Text "Ignorable" -ConditionalTextColor DarkRed -BackgroundColor $null + New-ConditionalText -Range "C:C" -ConditionalType ContainsText -Text "Cleanup" -ConditionalTextColor DarkRed -BackgroundColor $null + New-ConditionalText -Range "C:C" -ConditionalType ContainsText -Text "Sharing" -ConditionalTextColor Blue -BackgroundColor $null + + # TriggerAction + New-ConditionalText -Range "G:G" -ConditionalType ContainsText -Text "Create" -ConditionalTextColor Green -BackgroundColor $null + New-ConditionalText -Range "G:G" -ConditionalType ContainsText -Text "Delete" -ConditionalTextColor Red -BackgroundColor $null + # ItemClass + New-ConditionalText -Range "H:H" -ConditionalType ContainsText -Text "IPM.Appointment" -ConditionalTextColor Blue -BackgroundColor $null + New-ConditionalText -Range "H:H" -ConditionalType ContainsText -Text "Cancellation" -ConditionalTextColor Black -BackgroundColor Orange + New-ConditionalText -Range "H:H" -ConditionalType ContainsText -Text ".Request" -ConditionalTextColor DarkGreen -BackgroundColor $null + New-ConditionalText -Range "H:H" -ConditionalType ContainsText -Text ".Resp." -ConditionalTextColor Orange -BackgroundColor $null + New-ConditionalText -Range "H:H" -ConditionalType ContainsText -Text "IPM.OLE.CLASS" -ConditionalTextColor Plum -BackgroundColor $null + + #FreeBusyStatus + New-ConditionalText -Range "L3:L9999" -ConditionalType ContainsText -Text "Free" -ConditionalTextColor Red -BackgroundColor $null + New-ConditionalText -Range "L3:L9999" -ConditionalType ContainsText -Text "Tentative" -ConditionalTextColor Orange -BackgroundColor $null + New-ConditionalText -Range "L3:L9999" -ConditionalType ContainsText -Text "Busy" -ConditionalTextColor Green -BackgroundColor $null + + #Shared Calendar information + New-ConditionalText -Range "Q3:Q9999" -ConditionalType NotEqual -Text "Not Shared" -ConditionalTextColor Blue -BackgroundColor $null + New-ConditionalText -Range "R:R" -ConditionalType ContainsText -Text "TRUE" -ConditionalTextColor Blue -BackgroundColor $null + New-ConditionalText -Range "S:S" -ConditionalType NotEqual -Text "NotFound" -ConditionalTextColor Blue -BackgroundColor $null + + #MeetingRequestType + New-ConditionalText -Range "V:V" -ConditionalType ContainsText -Text "Outdated" -ConditionalTextColor DarkRed -BackgroundColor LightPink + + #AppointmentAuxiliaryFlags + New-ConditionalText -Range "AE3:AE9999" -ConditionalType ContainsText -Text "Copied" -ConditionalTextColor DarkRed -BackgroundColor LightPink + + #ResponseType + New-ConditionalText -Range "AI3:AI9999" -ConditionalType ContainsText -Text "Organizer" -ConditionalTextColor Orange -BackgroundColor $null +) + +function FormatHeader { + param( + [object] $excel + ) + $sheet = $excel.Workbook.Worksheets[$ShortId] + $HeaderRow = 2 + $n = 0 + + # Static List of Columns for now... + $sheet.Column(++$n) | Set-ExcelRange -Width 6 -HorizontalAlignment center # LogRow + Set-CellComment -Text "This is the Enhanced Calendar Logs for [$Identity] for MeetingID `n [$($script:GCDO[0].CleanGlobalObjectId)]." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 20 -NumberFormat "m/d/yyyy h:mm:ss" -HorizontalAlignment center #LogTimestamp + Set-CellComment -Text "LogTimestamp: Time when the change was recorded in the CalLogs. This and all Times are in UTC." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 11 -HorizontalAlignment center # LogType + Set-CellComment -Text "LogType: Grouping of logs so ignorable ones can be quickly filtered?" -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 20 -HorizontalAlignment Left # SubjectProperty + Set-CellComment -Text "SubjectProperty: The Subject of the Meeting." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 20 -HorizontalAlignment Left # Client + Set-CellComment -Text "Client (ShortClientInfoString): The 'friendly' Client name of the client that made the change." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 5 -HorizontalAlignment Left # LogClientInfoString + Set-CellComment -Text "LogClientInfoString: Full Client Info String of client that made the change." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 12 -HorizontalAlignment Center # TriggerAction + Set-CellComment -Text "TriggerAction (CalendarLogTriggerAction): The type of action that caused the change." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 18 -HorizontalAlignment Left # ItemClass + Set-CellComment -Text "ItemClass: The Class of the Calendar Item" -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment center # Seq:Exp:ItemVersion + Set-CellComment -Text "Seq:Exp:ItemVersion (AppointmentLastSequenceNumber:AppointmentSequenceNumber:ItemVersion): The Sequence Version, the Exception Version, and the Item Version. Each type of item has its own count." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 20 -HorizontalAlignment Left # Organizer + Set-CellComment -Text "Organizer (From.FriendlyDisplayName): The Organizer of the Calendar Item." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 20 -HorizontalAlignment Left # From + Set-CellComment -Text "From: The SMTP address of the Organizer of the Calendar Item." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 12 -HorizontalAlignment center # FreeBusyStatus + Set-CellComment -Text "FreeBusy (FreeBusyStatus): The FreeBusy Status of the Calendar Item." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 20 -HorizontalAlignment Left # ResponsibleUser + Set-CellComment -Text "ResponsibleUser(ResponsibleUserName): The Responsible User of the change." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 20 -HorizontalAlignment Left # Sender + Set-CellComment -Text "Sender (SenderEmailAddress): The Sender of the change." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 16 -HorizontalAlignment Left # LogFolder + Set-CellComment -Text "LogFolder (ParentDisplayName): The Log Folder that the CalLog was in." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 16 -HorizontalAlignment Left # OriginalLogFolder + Set-CellComment -Text "OriginalLogFolder (OriginalParentDisplayName): The Original Log Folder that the item was in / delivered to." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 15 -HorizontalAlignment Right # SharedFolderName + Set-CellComment -Text "SharedFolderName: Was this from a Modern Sharing, and if so what Folder." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment center # IsFromSharedCalendar + Set-CellComment -Text "IsFromSharedCalendar: Is this CalLog from a Modern Sharing relationship?" -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 20 -HorizontalAlignment Left # ExternalSharingMasterId + Set-CellComment -Text "ExternalSharingMasterId: If this is not [NotFound], then it is from a Modern Sharing relationship." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment Left # ReceivedBy + Set-CellComment -Text "ReceivedBy: The Receiver of the Calendar Item. Should always be the owner of the Mailbox." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment Left # ReceivedRepresenting + Set-CellComment -Text "ReceivedRepresenting: Who the item was Received for, of then the Delegate." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment center # MeetingRequestType + Set-CellComment -Text "MeetingRequestType: The Meeting Request Type of the Meeting." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 20 -NumberFormat "m/d/yyyy h:mm:ss" -HorizontalAlignment center # StartTime + Set-CellComment -Text "StartTime: The Start Time of the Meeting. This and all Times are in UTC." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 20 -NumberFormat "m/d/yyyy h:mm:ss" -HorizontalAlignment center # EndTime + Set-CellComment -Text "EndTime: The End Time of the Meeting. This and all Times are in UTC." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 17 -NumberFormat "m/d/yyyy h:mm:ss" -HorizontalAlignment Left # OriginalStartDate + Set-CellComment -Text "OriginalStartDate: The Original Start Date of the Meeting." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment Left # TimeZone + Set-CellComment -Text "TimeZone: The Time Zone of the Meeting." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment Left # Location + Set-CellComment -Text "Location: The Location of the Meeting." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment center # CalendarItemType + Set-CellComment -Text "CalendarItemType: The Calendar Item Type of the Meeting." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment center # IsException + Set-CellComment -Text "IsException: Is this an Exception?" -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 20 -HorizontalAlignment Left # RecurrencePattern + Set-CellComment -Text "RecurrencePattern: The Recurrence Pattern of the Meeting." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 30 -HorizontalAlignment Center # AppointmentAuxiliaryFlags + Set-CellComment -Text "AppointmentAuxiliaryFlags: The Appointment Auxiliary Flags of the Meeting." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 30 -HorizontalAlignment Left # DisplayAttendeesAll + Set-CellComment -Text "DisplayAttendeesAll: List of the Attendees of the Meeting." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment center # AttendeeCount + Set-CellComment -Text "AttendeeCount: The Attendee Count." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 20 -HorizontalAlignment Left # AppointmentState + Set-CellComment -Text "AppointmentState: The Appointment State of the Meeting." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment center # ResponseType + Set-CellComment -Text "ResponseType: The Response Type of the Meeting." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 20 -HorizontalAlignment center # ClientIntent + Set-CellComment -Text "ClientIntent: The Client Intent of the Meeting." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment center # AppointmentRecurring + Set-CellComment -Text "AppointmentRecurring: Is this a Recurring Meeting?" -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment center # HasAttachment + Set-CellComment -Text "HasAttachment: Does this Meeting have an Attachment?" -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment center # IsCancelled + Set-CellComment -Text "IsCancelled: Is this Meeting Cancelled?" -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment center # IsAllDayEvent + Set-CellComment -Text "IsAllDayEvent: Is this an All Day Event?" -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 10 -HorizontalAlignment center # IsSeriesCancelled + Set-CellComment -Text "IsSeriesCancelled: Is this a Series Cancelled Meeting?" -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 30 -HorizontalAlignment Left # SendMeetingMessagesDiagnostics + Set-CellComment -Text "SendMeetingMessagesDiagnostics: Compound Property to describe why meeting was or was not sent to everyone." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 50 -HorizontalAlignment Left # AttendeeCollection + Set-CellComment -Text "AttendeeCollection: The Attendee Collection of the Meeting, use -TrackingLogs to get values." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 40 -HorizontalAlignment Center # CalendarLogRequestId + Set-CellComment -Text "CalendarLogRequestId: The Calendar Log Request ID of the Meeting." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + $sheet.Column(++$n) | Set-ExcelRange -Width 120 -HorizontalAlignment Left # CleanGlobalObjectId + Set-CellComment -Text "CleanGlobalObjectId: The Clean Global Object ID of the Meeting." -Row $HeaderRow -ColumnNumber $n -Worksheet $sheet + + # Update header rows after all the others have been set. + # Title Row + $sheet.Row(1) | Set-ExcelRange -HorizontalAlignment Left + + # Set the Header row to be bold and left aligned + $sheet.Row($HeaderRow) | Set-ExcelRange -Bold -HorizontalAlignment Left +} diff --git a/Calendar/CalLogHelpers/Invoke-GetCalLogs.ps1 b/Calendar/CalLogHelpers/Invoke-GetCalLogs.ps1 index b3df2d1ab4..fdc4843d12 100644 --- a/Calendar/CalLogHelpers/Invoke-GetCalLogs.ps1 +++ b/Calendar/CalLogHelpers/Invoke-GetCalLogs.ps1 @@ -30,6 +30,7 @@ $script:CustomPropertyNameList = "SendMeetingMessagesDiagnostics", "SentRepresentingDisplayName", "SentRepresentingEmailAddress", +"Sensitivity", "LogTimestamp", "LogClientInfoString", "OriginalStartDate", diff --git a/Calendar/CalLogHelpers/Invoke-GetMailbox.ps1 b/Calendar/CalLogHelpers/Invoke-GetMailbox.ps1 index 801e435f11..616429cb06 100644 --- a/Calendar/CalLogHelpers/Invoke-GetMailbox.ps1 +++ b/Calendar/CalLogHelpers/Invoke-GetMailbox.ps1 @@ -5,7 +5,6 @@ $WellKnownCN_CA = "MICROSOFT SYSTEM ATTENDANT" $CalAttendant = "Calendar Assistant" $WellKnownCN_Trans = "MicrosoftExchange" $Transport = "Transport Service" - <# .SYNOPSIS Get the Mailbox for the Passed in Identity. @@ -18,46 +17,59 @@ Might want to extend to do 'Get-MailUser' as well. function GetMailbox { param( [string]$Identity, - [string]$Organization + [string]$Organization, + [bool]$UseGetMailbox ) - try { - Write-Verbose "Searching Get-Mailbox $(if (-not ([string]::IsNullOrEmpty($Organization))) {"with Org: $Organization"}) for $Identity." + if ($UseGetMailbox) { + $Cmdlet = "Get-Mailbox" + } else { + $Cmdlet = "Get-Recipient" + } + $params = @{Identity = $Identity + ErrorAction = "SilentlyContinue" + } - if ($Identity -and $Organization) { - if ($script:MSSupport) { - Write-Verbose "Using Organization parameter" - $GetMailboxOutput = Get-Mailbox -Identity $Identity -Organization $Organization -ErrorAction SilentlyContinue - } else { - Write-Verbose "Using -OrganizationalUnit parameter" - $GetMailboxOutput = Get-Mailbox -Identity $Identity -OrganizationalUnit $Organization -ErrorAction SilentlyContinue - } - } else { - $GetMailboxOutput = Get-Mailbox -Identity $Identity -ErrorAction SilentlyContinue + try { + Write-Verbose "Searching $Cmdlet $(if (-not ([string]::IsNullOrEmpty($Organization))) {"with Org: $Organization"}) for $Identity." + + if (-not ([string]::IsNullOrEmpty($Organization)) -and $script:MSSupport) { + Write-Verbose "Using Organization parameter" + $params.Add("Organization", $Organization) + } elseif (-not ([string]::IsNullOrEmpty($Organization))) { + Write-Verbose "Using -OrganizationalUnit parameter with $Organization." + $params.Add("Organization", $Organization) } - if (!$GetMailboxOutput) { + Write-Verbose "Running $Cmdlet with params: $($params.Values)" + $RecipientOutput = & $Cmdlet @params + Write-Verbose "RecipientOutput: $RecipientOutput" + + if (!$RecipientOutput) { Write-Host "Unable to find [$Identity]$(if ($Organization -ne `"`" ) {" in Organization:[$Organization]"})." Write-Host "Trying to find a Group Mailbox for [$Identity]..." - $GetMailboxOutput = Get-Mailbox -Identity $Identity -ErrorAction SilentlyContinue -GroupMailbox - if (!$GetMailboxOutput) { + $RecipientOutput = Get-Mailbox -Identity $Identity -ErrorAction SilentlyContinue -GroupMailbox + if (!$RecipientOutput) { Write-Host "Unable to find a Group Mailbox for [$Identity] either." return $null } else { - Write-Verbose "Found GroupMailbox [$($GetMailboxOutput.DisplayName)]" + Write-Verbose "Found GroupMailbox [$($RecipientOutput.DisplayName)]" } - } else { - Write-Verbose "Found [$($GetMailboxOutput.DisplayName)]" } - if (CheckForNoPIIAccess($script:GetMailboxOutput.DisplayName)) { - Write-Host -ForegroundColor Magenta "No PII Access for [$Identity]" + if ($null -eq $script:PIIAccess) { + [bool]$script:PIIAccess = CheckForPIIAccess($RecipientOutput.DisplayName) + } + + if ($script:PIIAccess) { + Write-Verbose "Found [$($RecipientOutput.DisplayName)]" } else { - Write-Verbose "Found [$($GetMailboxOutput.DisplayName)]" + Write-Host -ForegroundColor Magenta "No PII Access for [$Identity]" } - return $GetMailboxOutput + + return $RecipientOutput } catch { - Write-Error "An error occurred while running Get-Mailbox: [$_]" + Write-Error "An error occurred while running ${Cmdlet}: [$_]" } } @@ -84,13 +96,13 @@ function CheckIdentities { Write-Host "Preparing to check $($Identity.count) Mailbox(es)..." foreach ($Id in $Identity) { - $Account = GetMailbox -Identity $Id + $Account = GetMailbox -Identity $Id -UseGetMailbox $true if ($null -eq $Account) { # -or $script:MB.GetType().FullName -ne "Microsoft.Exchange.Data.Directory.Management.Mailbox") { Write-DashLineBoxColor "`n Error: Mailbox [$Id] not found on Exchange Online. Please validate the mailbox name and try again.`n" -Color Red continue } - if (CheckForNoPIIAccess $Account.DisplayName) { + if (-not (CheckForPIIAccess($Account.DisplayName))) { Write-Host -ForegroundColor DarkRed "No PII access for Mailbox [$Id]. Falling back to SMTP Address." $IdentityList += $ID if ($null -eq $script:MB) { @@ -104,11 +116,16 @@ function CheckIdentities { } } if ($Account.CalendarVersionStoreDisabled -eq $true) { + [bool]$script:CalLogsDisabled = $true Write-Host -ForegroundColor DarkRed "Mailbox [$Id] has CalendarVersionStoreDisabled set to True. This mailbox will not have Calendar Logs." Write-Host -ForegroundColor DarkRed "Some logs will be available for Mailbox [$Id] but they will not be complete." } if ($Account.RecipientTypeDetails -eq "RoomMailbox" -or $Account.RecipientTypeDetails -eq "EquipmentMailbox") { - $script:Rooms += $Account.PrimarySmtpAddress.ToString() + if ($script:PIIAccess -eq $true) { + $script:Rooms += $Account.PrimarySmtpAddress.ToString() + } else { + $script:Rooms += $Id + } Write-Host -ForegroundColor Green "[$Id] is a Room / Equipment Mailbox." } } @@ -262,14 +279,14 @@ function BetterThanNothingCNConversion { .SYNOPSIS Checks if an entries is Redacted to protect PII. #> -function CheckForNoPIIAccess { +function CheckForPIIAccess { param( $PassedString ) if ($PassedString -match "REDACTED-") { - return $true - } else { return $false + } else { + return $true } } @@ -314,7 +331,7 @@ function GetMailboxProp { } Write-Verbose "`t GetMailboxProp:[$Prop] :Found::[$ReturnValue]" - if (CheckForNoPIIAccess($ReturnValue)) { + if (-not (CheckForPIIAccess($ReturnValue))) { Write-Verbose "No PII Access for [$ReturnValue]" return BetterThanNothingCNConversion($PassedCN) } diff --git a/Calendar/CalLogHelpers/ShortClientNameFunctions.ps1 b/Calendar/CalLogHelpers/ShortClientNameFunctions.ps1 index 914ef5eb4b..2953c3d590 100644 --- a/Calendar/CalLogHelpers/ShortClientNameFunctions.ps1 +++ b/Calendar/CalLogHelpers/ShortClientNameFunctions.ps1 @@ -58,6 +58,11 @@ function CreateShortClientName { return $ShortClientName } + if ($LogClientInfoString -like "*EDiscoverySearch*") { + $ShortClientName = "EDiscoverySearch" + return $ShortClientName + } + if ($LogClientInfoString -like "Client=EBA*" -or $LogClientInfoString -like "Client=TBA*") { if ($LogClientInfoString -like "*ResourceBookingAssistant*") { $ShortClientName = "ResourceBookingAssistant" diff --git a/Calendar/CalLogHelpers/TimelineFunctions.ps1 b/Calendar/CalLogHelpers/TimelineFunctions.ps1 index eb22ce5cbb..aa40f1f67a 100644 --- a/Calendar/CalLogHelpers/TimelineFunctions.ps1 +++ b/Calendar/CalLogHelpers/TimelineFunctions.ps1 @@ -75,6 +75,11 @@ function BuildTimeline { Write-Host "Found $($script:EnhancedCalLogs.count) Log entries, only the $($InterestingCalLogs.count) Non-Ignorable entries will be analyzed in the TimeLine. `n" } + if ($script:CalLogsDisabled) { + Write-Host -ForegroundColor Red "Warning: CalLogs are disabled for this user, Timeline / CalLogs will be incomplete." + return + } + Write-DashLineBoxColor " TimeLine for: [$Identity]", " Subject: $($script:GCDO[0].NormalizedSubject)", " Organizer: $Script:Organizer", diff --git a/Calendar/Check-SharingStatus.ps1 b/Calendar/Check-SharingStatus.ps1 index c11b57880b..f16aedd58c 100644 --- a/Calendar/Check-SharingStatus.ps1 +++ b/Calendar/Check-SharingStatus.ps1 @@ -429,9 +429,9 @@ function GetReceiverInformation { # need to check if Get-CalendarValidationResult in the PS Workspace if ((Get-Command -Name Get-CalendarValidationResult -ErrorAction SilentlyContinue) -and $null -ne $ReceiverCalEntries) { - Write-Host "Running cmdlet: Get-CalendarValidationResult -Version V2 -Identity $Receiver -SourceCalendarId $($ReceiverCalEntries[0].LocalFolderId) -TargetUserId $Owner -IncludeAnalysis 1 -OnlyReportErrors 1" $ewsId_del= $ReceiverCalEntries[0].LocalFolderId - Get-CalendarValidationResult -Version V2 -Identity $Receiver -SourceCalendarId $ewsId_del -TargetUserId $Owner -IncludeAnalysis 1 -OnlyReportErrors 1 + Write-Host "Running cmdlet: Get-CalendarValidationResult -Version V2 -Identity $Receiver -SourceCalendarId $ewsId_del -TargetUserId $Owner -IncludeAnalysis 1 -OnlyReportErrors 1 | FT -a GlobalObjectId, EventValidationResult " + Get-CalendarValidationResult -Version V2 -Identity $Receiver -SourceCalendarId $ewsId_del -TargetUserId $Owner -IncludeAnalysis 1 -OnlyReportErrors 1 | Format-List UserPrimarySMTPAddress, Subject, GlobalObjectId, EventValidationResult, EventComparisonResult } } diff --git a/Calendar/Get-CalendarDiagnosticObjectsSummary.ps1 b/Calendar/Get-CalendarDiagnosticObjectsSummary.ps1 index 8c4acac385..8684ad28f6 100644 --- a/Calendar/Get-CalendarDiagnosticObjectsSummary.ps1 +++ b/Calendar/Get-CalendarDiagnosticObjectsSummary.ps1 @@ -26,6 +26,9 @@ # .PARAMETER CaseNumber # Case Number to include in the Filename of the output. # +# .PARAMETER ShortLogs +# Limit Logs to 500 instead of the default 2000, in case the server has trouble responding with the full logs. +# # .EXAMPLE # Get-CalendarDiagnosticObjectsSummary.ps1 -Identity someuser@microsoft.com -MeetingID 040000008200E00074C5B7101A82E008000000008063B5677577D9010000000000000000100000002FCDF04279AF6940A5BFB94F9B9F73CD # @@ -45,6 +48,7 @@ param ( [string[]]$Identity, [switch]$ExportToExcel, [string]$CaseNumber, + [switch]$ShortLogs, [Parameter(Mandatory, ParameterSetName = 'MeetingID', Position = 1)] [string]$MeetingID, @@ -79,11 +83,15 @@ Write-Verbose "Script Versions: $BuildVersion" . $PSScriptRoot\CalLogHelpers\ShortClientNameFunctions.ps1 . $PSScriptRoot\CalLogHelpers\CalLogInfoFunctions.ps1 . $PSScriptRoot\CalLogHelpers\CalLogExportFunctions.ps1 -. $PSScriptRoot\CalLogHelpers\ExcelModuleInstaller.ps1 . $PSScriptRoot\CalLogHelpers\CreateTimelineRow.ps1 . $PSScriptRoot\CalLogHelpers\FindChangedPropFunctions.ps1 . $PSScriptRoot\CalLogHelpers\Write-DashLineBoxColor.ps1 +if ($ExportToExcel.IsPresent) { + . $PSScriptRoot\CalLogHelpers\ExcelModuleInstaller.ps1 + . $PSScriptRoot\CalLogHelpers\ExportToExcelFunctions.ps1 +} + # =================================================================================================== # Main # =================================================================================================== From 1d9e7e6bbd1e5994d82fe9e397b67b7d4fae36e1 Mon Sep 17 00:00:00 2001 From: Shane Ferrell Date: Tue, 16 Jul 2024 08:20:34 -0700 Subject: [PATCH 2/2] Minor change to rerun validation --- Calendar/CalLogHelpers/Invoke-GetMailbox.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Calendar/CalLogHelpers/Invoke-GetMailbox.ps1 b/Calendar/CalLogHelpers/Invoke-GetMailbox.ps1 index 616429cb06..ea894111bd 100644 --- a/Calendar/CalLogHelpers/Invoke-GetMailbox.ps1 +++ b/Calendar/CalLogHelpers/Invoke-GetMailbox.ps1 @@ -64,7 +64,7 @@ function GetMailbox { if ($script:PIIAccess) { Write-Verbose "Found [$($RecipientOutput.DisplayName)]" } else { - Write-Host -ForegroundColor Magenta "No PII Access for [$Identity]" + Write-Verbose "No PII Access for [$Identity]" } return $RecipientOutput