Skip to content

Commit

Permalink
First checkin
Browse files Browse the repository at this point in the history
  • Loading branch information
Shanefe committed Sep 24, 2024
1 parent fa886e8 commit 8433f82
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 17 deletions.
46 changes: 40 additions & 6 deletions Calendar/CalLogHelpers/CalLogCSVFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ function BuildCSV {

Write-Host "Starting to Process Calendar Logs..."
$GCDOResults = @()
$IsFromSharedCalendar = @()
$LogType = @()
$script:MailboxList = @{}
Write-Host "Creating Map of Mailboxes to CNs..."
Expand All @@ -157,8 +156,6 @@ function BuildCSV {
}
}

$IsFromSharedCalendar = ($null -ne $CalLog.externalSharingMasterId -and $CalLog.externalSharingMasterId -ne "NotFound")

# Record one row
$GCDOResults += [PSCustomObject]@{
'LogRow' = $Index
Expand All @@ -169,7 +166,7 @@ function BuildCSV {
'LogClientInfoString' = $CalLog.LogClientInfoString
'TriggerAction' = $CalLog.CalendarLogTriggerAction
'ItemClass' = $ItemType
'Seq:Exp:ItemVersion' = $CalLog.AppointmentSequenceNumber.ToString() + ":" + $CalLog.AppointmentLastSequenceNumber.ToString() + ":" + $CalLog.ItemVersion.ToString()
'Seq:Exp:ItemVersion' = CompressedVersion
'Organizer' = $CalLog.From.FriendlyDisplayName
'From' = GetBestFromAddress($CalLog.From)
'FreeBusy' = $CalLog.FreeBusyStatus.ToString()
Expand All @@ -178,7 +175,6 @@ function BuildCSV {
'LogFolder' = $CalLog.ParentDisplayName
'OriginalLogFolder' = $CalLog.OriginalParentDisplayName
'SharedFolderName' = MapSharedFolder($CalLog.ExternalSharingMasterId)
'IsFromSharedCalendar' = $IsFromSharedCalendar
'ReceivedBy' = $CalLog.ReceivedBy.SmtpEmailAddress
'ReceivedRepresenting' = $CalLog.ReceivedRepresenting.SmtpEmailAddress
'MeetingRequestType' = $CalLog.MeetingRequestType.ToString()
Expand All @@ -192,7 +188,7 @@ function BuildCSV {
'RecurrencePattern' = $CalLog.RecurrencePattern
'AppointmentAuxiliaryFlags' = $CalLog.AppointmentAuxiliaryFlags.ToString()
'DisplayAttendeesAll' = $CalLog.DisplayAttendeesAll
'AttendeeCount' = ($CalLog.DisplayAttendeesAll -split ';').Count
'AttendeeCount' = GetAttendeeCount($CalLog.DisplayAttendeesAll)
'AppointmentState' = $CalLog.AppointmentState.ToString()
'ResponseType' = $CalLog.ResponseType.ToString()
'ClientIntent' = $CalLog.ClientIntent.ToString()
Expand Down Expand Up @@ -223,3 +219,41 @@ function ConvertDateTime {
}
return [DateTime]$DateTime
}

function GetAttendeeCount {
param(
[string] $AttendeeCollection
)
if ($From.SmtpAddress -ne "NotFound") {
return ($AttendeeCollection -split ';').Count
} else {
return "-"
}
}

function CompressedVersion
{
[string] $CompressedString = ""
if ($CalLog.AppointmentSequenceNumber -eq "NotFound" -or [string]::IsNullOrEmpty($CalLog.AppointmentSequenceNumber))
{
$CompressedString = "-:"
} else {
$CompressedString = $CalLog.AppointmentSequenceNumber.ToString() + ":"
}
if ($CalLog.AppointmentLastSequenceNumber -eq "NotFound" -or [string]::IsNullOrEmpty($CalLog.AppointmentLastSequenceNumber))
{
$CompressedString += "-:"
} else {

$CompressedString += $CalLog.AppointmentLastSequenceNumber.ToString() + ":"
}
if ($CalLog.ItemVersion -eq "NotFound" -or [string]::IsNullOrEmpty($CalLog.ItemVersion))
{
$CompressedString += "-"
} else {
$CompressedString += $CalLog.ItemVersion.ToString()

}

return $CompressedString
}
8 changes: 4 additions & 4 deletions Calendar/CalLogHelpers/CreateTimelineRow.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ function CreateTimelineRow {
} else {
switch ($CalLog.Client) {
ResourceBookingAssistant {
[array] $Output = "ResourceBookingAssistant $($Action) a $($MeetingRespType) Meeting Response message."
[array] $Output = "ResourceBookingAssistant $($Action) a $($MeetingRespType) Meeting Response message$($Extra)."
}
Transport {
[array] $Output = "[$($CalLog.From)] $($Action) $($MeetingRespType) Meeting Response message."
[array] $Output = "[$($CalLog.From)] $($Action) $($MeetingRespType) Meeting Response message$($Extra)."
}
default {
[array] $Output = "[$($CalLog.ResponsibleUser)] $($Action) [$($CalLog.Organizer)]'s $($MeetingRespType) Meeting Response with $($CalLog.Client)."
[array] $Output = "[$($CalLog.ResponsibleUser)] $($Action) [$($CalLog.Organizer)]'s $($MeetingRespType) Meeting Response with $($CalLog.Client)$($Extra)."
}
}
}
Expand All @@ -114,7 +114,7 @@ function CreateTimelineRow {
}
Exception {
if ($CalLog.ResponsibleUser -ne "Calendar Assistant") {
[array] $Output = "[$($CalLog.ResponsibleUser)] $($CalLog.TriggerAction)d Exception to the meeting series with $($CalLog.Client)."
[array] $Output = "[$($CalLog.ResponsibleUser)] $($CalLog.TriggerAction)d Exception starting $($CalLog.StartTime) to the meeting series with $($CalLog.Client)."
}
}
Ipm.Appointment {
Expand Down
46 changes: 39 additions & 7 deletions Calendar/CalLogHelpers/ExportToExcelFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,32 @@ function Export-CalLogExcel {
# 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
LogScriptInfo
}

function LogScriptInfo {
# Only need to run once per script.
if ($null -eq $script:CollectedCmdLine) {
$commandLine = $MyInvocation.Line
Write-Output "The script was started with the following command line:"
Write-Output $commandLine

$RunInfo += [PSCustomObject]@{
"Script" = $MyInvocation.MyCommand.Name
"RunTime" = Get-Date
"Command" = $commandLine
"version" = $script:Version
"User" = whoami.exe
"PowerShell Version" = $PSVersionTable.PSVersion
"OS" = $(Get-WmiObject -Class Win32_OperatingSystem).Version
"More Info:" = "https://learn.microsoft.com/en-us/exchange/troubleshoot/calendars/get-calendar-diagnostic-logs#use-the-get-calendardiagnosticobjectssummaryps1-script."
}

$RunInfo | Export-Excel -Path $FileName -WorksheetName "ScriptInfo" -MoveToEnd
$script:CollectedCmdLine = $true
}
# If someone runs the script the script again, will need to see what happens.
# The script will update the information, i.e. add a new users logs, but what happenes with ScriptInfo?
}

function Export-TimelineExcel {
Expand Down Expand Up @@ -71,9 +97,9 @@ $ConditionalFormatting = $(
New-ConditionalText "[Unknown Rest Client]" -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
#LogType -Would like to Hide "Ignorable" and "Cleanup" rows by default.
New-ConditionalText -Range "C3:C9999" -ConditionalType ContainsText -Text "Ignorable" -ConditionalTextColor Orange -BackgroundColor $null
New-ConditionalText -Range "C:C" -ConditionalType ContainsText -Text "Cleanup" -ConditionalTextColor Orange -BackgroundColor $null
New-ConditionalText -Range "C:C" -ConditionalType ContainsText -Text "Sync" -ConditionalTextColor Blue -BackgroundColor $null

# TriggerAction
Expand All @@ -92,13 +118,17 @@ $ConditionalFormatting = $(
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 "Q3:Q9999" -ConditionalType Equal -Text "Not Shared" -ConditionalTextColor Blue -BackgroundColor $null
New-ConditionalText -Range "Q3:Q9999" -ConditionalType Equal -Text "TRUE" -ConditionalTextColor Blue -BackgroundColor Orange

#MeetingRequestType
New-ConditionalText -Range "T:T" -ConditionalType ContainsText -Text "Outdated" -ConditionalTextColor DarkRed -BackgroundColor LightPink

#CalendarItemType
New-ConditionalText -Range "AA3:AA9999" -ConditionalType ContainsText -Text "RecurringMaster" -ConditionalTextColor $null -BackgroundColor Plum

#AppointmentAuxiliaryFlags
New-ConditionalText -Range "AC3:AC9999" -ConditionalType ContainsText -Text "Copied" -ConditionalTextColor DarkRed -BackgroundColor LightPink
New-ConditionalText -Range "AD3:AD9999" -ConditionalType ContainsText -Text "Copied" -ConditionalTextColor DarkRed -BackgroundColor LightPink
New-ConditionalText -Range "AC3:AC9999" -ConditionalType ContainsText -Text "ForwardedAppointment" -ConditionalTextColor DarkRed -BackgroundColor $null

#ResponseType
Expand All @@ -110,6 +140,7 @@ function FormatHeader {
[object] $excel
)
$sheet = $excel.Workbook.Worksheets[$ShortId]
# Set-CellComment -Text "For more information see: https://learn.microsoft.com/en-us/exchange/troubleshoot/calendars/get-calendar-diagnostic-logs#use-the-get-calendardiagnosticobjectssummaryps1-script." -Row 1 -ColumnNumber 1 -Worksheet $sheet
$HeaderRow = 2
$n = 0

Expand Down Expand Up @@ -146,7 +177,7 @@ function FormatHeader {
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
$sheet.Column(++$n) | Set-ExcelRange -Width 15 -HorizontalAlignment Left # 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 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
Expand Down Expand Up @@ -202,7 +233,8 @@ function FormatHeader {
# Update header rows after all the others have been set.
# Title Row
$sheet.Row(1) | Set-ExcelRange -HorizontalAlignment Left

Set-CellComment -Text "For more information see: https://learn.microsoft.com/en-us/exchange/troubleshoot/calendars/analyze-calendar-diagnostic-logs." -Row 1 -ColumnNumber 1 -Worksheet $sheet

# Set the Header row to be bold and left aligned
$sheet.Row($HeaderRow) | Set-ExcelRange -Bold -HorizontalAlignment Left
}
2 changes: 2 additions & 0 deletions Calendar/CalLogHelpers/TimelineFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ function BuildTimeline {
}

Write-DashLineBoxColor " TimeLine for: [$Identity]",
"CollectionDate: $($(Get-Date).ToString("yyyy-MM-dd HH:mm:ss"))",
"ScriptVersion: $ScriptVersion",
" Subject: $($script:GCDO[0].NormalizedSubject)",
" Organizer: $Script:Organizer",
" MeetingID: $($script:GCDO[0].CleanGlobalObjectId)"
Expand Down
2 changes: 2 additions & 0 deletions Calendar/Get-CalendarDiagnosticObjectsSummary.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ if (-not ([string]::IsNullOrEmpty($Subject)) ) {
}

Write-DashLineBoxColor "Hope this script was helpful in getting and understanding the Calendar Logs.",
"More Info on Getting the logs: https://learn.microsoft.com/en-us/exchange/troubleshoot/calendars/get-calendar-diagnostic-logs",
"and More Info on Analying the logs: https://learn.microsoft.com/en-us/exchange/troubleshoot/calendars/analyze-calendar-diagnostic-logs"
"If you have issues or suggestion for this script, please send them to: ",
"`t [email protected]" -Color Yellow -DashChar =

Expand Down

0 comments on commit 8433f82

Please sign in to comment.