Skip to content

Commit

Permalink
Merge pull request #2216 from Shanefe/CalLogs-Use_Prod_Code
Browse files Browse the repository at this point in the history
CalLogs - Switch to Prod code
  • Loading branch information
dpaulson45 authored Nov 6, 2024
2 parents 76895e2 + 83ebb40 commit 9c6abb0
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 472 deletions.
10 changes: 3 additions & 7 deletions Calendar/CalLogHelpers/CalLogCSVFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function CreateExternalMasterIDMap {
foreach ($Key in $SharedFolders.Keys) {
Write-Host -ForegroundColor Green "$Key : $($SharedFolders[$Key])"
}
# ToDo: Need to check for multiple ExternalMasterIDs pointing to the same FolderName
# ToDo: Need to check for multiple ExternalSharingMasterId pointing to the same FolderName
Write-Verbose "Created the following Mapping :"
Write-Verbose $SharedFolders
}
Expand Down Expand Up @@ -131,7 +131,6 @@ function BuildCSV {

Write-Host "Starting to Process Calendar Logs..."
$GCDOResults = @()
$LogType = @()
$script:MailboxList = @{}
Write-Host "Creating Map of Mailboxes to CNs..."
CreateExternalMasterIDMap
Expand All @@ -144,9 +143,6 @@ function BuildCSV {
$Index++
$ItemType = $CalendarItemTypes.($CalLog.ItemClass)

$ShortClientName = CreateShortClientName($CalLog.LogClientInfoString)
$LogType = SetLogType($CalLog)

# CleanNotFounds
$PropsToClean = "FreeBusyStatus", "ClientIntent", "AppointmentSequenceNumber", "AppointmentLastSequenceNumber", "RecurrencePattern", "AppointmentAuxiliaryFlags", "EventEmailReminderTimer", "IsSeriesCancelled", "AppointmentCounterProposal", "MeetingRequestType", "SendMeetingMessagesDiagnostics"
foreach ($Prop in $PropsToClean) {
Expand All @@ -160,9 +156,9 @@ function BuildCSV {
$GCDOResults += [PSCustomObject]@{
'LogRow' = $Index
'LogTimestamp' = ConvertDateTime($CalLog.LogTimestamp)
'LogType' = $LogType
'LogRowType' = $CalLog.LogRowType.ToString()
'SubjectProperty' = $CalLog.SubjectProperty
'Client' = $ShortClientName
'Client' = $CalLog.ShortClientInfoString
'LogClientInfoString' = $CalLog.LogClientInfoString
'TriggerAction' = $CalLog.CalendarLogTriggerAction
'ItemClass' = $ItemType
Expand Down
36 changes: 0 additions & 36 deletions Calendar/CalLogHelpers/CalLogInfoFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -100,39 +100,3 @@ function CheckForBifurcation {
return $IsBifurcated
}

<#
.SYNOPSIS
Sets the Calendar Log Type.
Many updates are not interesting in the Calendar Log, marking these as ignorable. 99% of the time this is correct.
#>
function SetLogType {
param(
$CalLog
)

if ($CalLog.ItemClass -eq "(Occurrence Deleted)") {
return "Ignorable"
} elseif ($ShortClientName -like "CalendarSyncAssistant" -or
$ShortClientName -eq "CalendarReplication" -or
$CalendarItemTypes.($CalLog.ItemClass) -eq "SharingCFM" -or
$CalendarItemTypes.($CalLog.ItemClass) -eq "SharingDelete") {
return "Sync"
} elseif ($ShortClientName -eq "Other EBA" -or
$ShortClientName -eq "Other TBA" -or
$ShortClientName -eq "LocationProcessor" -or
$ShortClientName -eq "GriffinRestClient" -or
$ShortClientName -eq "RestConnector" -or
$ShortClientName -eq "ELC-B2" -or
$ShortClientName -eq "TimeService" ) {
return "Ignorable"
} elseif ($CalLog.ItemClass -eq "IPM.OLE.CLASS.{00061055-0000-0000-C000-000000000046}" ) {
return "Exception"
} elseif (($CalendarItemTypes.($CalLog.ItemClass) -like "*Resp*" -and $CalLog.CalendarLogTriggerAction -ne "Create" ) -or
$CalendarItemTypes.($CalLog.ItemClass) -eq "AttendeeList" -or
($CalendarItemTypes.($CalLog.ItemClass) -eq "Forward.Notification" -and ($CalLog.CalendarLogTriggerAction -eq "SoftDelete") -or $CalLog.CalendarLogTriggerAction -like "*move*") -or
($CalLog.ItemClass -eq "IPM.Schedule.Meeting.Request" -and $CalLog.CalendarLogTriggerAction -like "*move*" ) ) {
return "Cleanup"
} else {
return "Core"
}
}
70 changes: 37 additions & 33 deletions Calendar/CalLogHelpers/ExportToExcelFunctions.ps1

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Calendar/CalLogHelpers/FindChangedPropFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Changed properties will be added to the Timeline.
#>
function FindChangedProperties {
if ($CalLog.Client -ne "LocationProcessor" -or $CalLog.Client -notlike "EBA:*" -or $CalLog.Client -notlike "TBA:*") {
if ($CalLog.Client -ne "LocationProcessor" -or $CalLog.Client -notlike "*EBA*" -or $CalLog.Client -notlike "*TBA*") {
if ($script:PreviousCalLog -and $script:AddChangedProperties) {
if ($CalLog.StartTime.ToString() -ne $script:PreviousCalLog.StartTime.ToString()) {
[Array]$TimeLineText = "The StartTime changed from [$($script:PreviousCalLog.StartTime)] to: [$($CalLog.StartTime)]"
Expand Down
20 changes: 12 additions & 8 deletions Calendar/CalLogHelpers/Invoke-GetCalLogs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ $script:CustomPropertyNameList =
"AppointmentLastSequenceNumber",
"AppointmentRecurring",
"CalendarItemType",
"CalendarLogTriggerAction",
"CalendarProcessed",
"ClientIntent",
"ChangeList",
"CalendarLogTriggerAction",
"ClientIntent",
"CreationTime",
"DisplayAttendeesCc",
"DisplayAttendeesTo",
"EventEmailReminderTimer",
Expand All @@ -22,20 +23,22 @@ $script:CustomPropertyNameList =
"From",
"HasAttachment",
"InternetMessageId",
"ItemID",
"IsAllDayEvent",
"IsCancelled",
"IsMeeting",
"IsOrganizerProperty",
"IsSharedInEvent",
"ItemID",
"LogClientInfoString",
"LogRowType",
"LogTimestamp",
"NormalizedSubject",
"OriginalStartDate",
"SendMeetingMessagesDiagnostics",
"Sensitivity",
"SentRepresentingDisplayName",
"SentRepresentingEmailAddress",
"Sensitivity",
"LogTimestamp",
"LogClientInfoString",
"OriginalStartDate",
"CreationTime",
"ShortClientInfoString",
"TimeZone"

$LogLimit = 2000
Expand Down Expand Up @@ -63,6 +66,7 @@ function GetCalendarDiagnosticObjects {
MaxResults = $LogLimit
ResultSize = $LogLimit
ShouldBindToItem = $true
ShouldDecodeEnums = $true
}

if ($TrackingLogs.IsPresent) {
Expand Down
178 changes: 0 additions & 178 deletions Calendar/CalLogHelpers/ShortClientNameFunctions.ps1

This file was deleted.

2 changes: 1 addition & 1 deletion Calendar/CalLogHelpers/TimelineFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function BuildTimeline {
FindOrganizer($script:FirstLog)

# Ignorable and items from Shared Calendars are not included in the TimeLine.
[array]$InterestingCalLogs = $script:EnhancedCalLogs | Where-Object { $_.LogType -eq "Core" -and $_.SharedFolderName -eq "Not Shared" }
[array]$InterestingCalLogs = $script:EnhancedCalLogs | Where-Object { $_.LogRowType -eq "Interesting" -and $_.SharedFolderName -eq "Not Shared" }

if ($InterestingCalLogs.count -eq 0) {
Write-Host "All CalLogs are Ignorable, nothing to create a timeline with, displaying initial values."
Expand Down
12 changes: 6 additions & 6 deletions Calendar/Get-CalendarDiagnosticObjectsSummary.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ if (Test-ScriptVersion -AutoUpdate -VersionsUrl "https://aka.ms/CL-VersionsUrl"

$script:command = $MyInvocation
Write-Verbose "The script was started with the following command line:"
Write-Verbose "Name: " $command.MyCommand.name
Write-Verbose "Command Line: " $command.line
Write-Verbose "Name: $($script:command.MyCommand.name)"
Write-Verbose "Command Line: $($script:command.line)"
Write-Verbose "Script Version: $BuildVersion"
$script:BuildVersion = $BuildVersion

Expand All @@ -97,14 +97,15 @@ $script:BuildVersion = $BuildVersion
. $PSScriptRoot\CalLogHelpers\MeetingSummaryFunctions.ps1
. $PSScriptRoot\CalLogHelpers\Invoke-GetMailbox.ps1
. $PSScriptRoot\CalLogHelpers\Invoke-GetCalLogs.ps1
. $PSScriptRoot\CalLogHelpers\ShortClientNameFunctions.ps1
. $PSScriptRoot\CalLogHelpers\CalLogInfoFunctions.ps1
. $PSScriptRoot\CalLogHelpers\CalLogExportFunctions.ps1
. $PSScriptRoot\CalLogHelpers\CreateTimelineRow.ps1
. $PSScriptRoot\CalLogHelpers\FindChangedPropFunctions.ps1
. $PSScriptRoot\CalLogHelpers\Write-DashLineBoxColor.ps1

if ($ExportToExcel.IsPresent) {
. $PSScriptRoot\..\Shared\Confirm-Administrator.ps1
$script:IsAdministrator = Confirm-Administrator
. $PSScriptRoot\CalLogHelpers\ExcelModuleInstaller.ps1
. $PSScriptRoot\CalLogHelpers\ExportToExcelFunctions.ps1
}
Expand Down Expand Up @@ -162,14 +163,13 @@ if (-not ([string]::IsNullOrEmpty($Subject)) ) {
if ($LogToExamine.count -gt 100) {
Write-Host -ForegroundColor Cyan "`t This is a large number of logs to examine, this may take a while."
}
Write-Host -ForegroundColor Cyan "`t Ignore the next [$($LogToExamine.count)] warnings..."
$logLeftCount = $LogToExamine.count

$ExceptionLogs = $LogToExamine | ForEach-Object {
$logLeftCount -= 1
Write-Verbose "Getting Exception Logs for [$($_.ItemId.ObjectId)]"
Get-CalendarDiagnosticObjects -Identity $ID -ItemIds $_.ItemId.ObjectId -ShouldFetchRecurrenceExceptions $true -CustomPropertyNames $CustomPropertyNameList -ShouldBindToItem $true
if ($logLeftCount % 20 -eq 0) {
Get-CalendarDiagnosticObjects -Identity $ID -ItemIds $_.ItemId.ObjectId -ShouldFetchRecurrenceExceptions $true -CustomPropertyNames $CustomPropertyNameList -ShouldBindToItem $true -WarningAction SilentlyContinue
if (($logLeftCount % 10 -eq 0) -and ($logLeftCount -gt 0)) {
Write-Host -ForegroundColor Cyan "`t [$($logLeftCount)] logs left to examine..."
}
}
Expand Down
Loading

0 comments on commit 9c6abb0

Please sign in to comment.