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
Copy file name to clipboardExpand all lines: Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardcalDefault.ps1
+70-54Lines changed: 70 additions & 54 deletions
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ function Invoke-CIPPStandardcalDefault {
16
16
EXECUTIVETEXT
17
17
Configures how much calendar information employees share by default with colleagues, balancing collaboration needs with privacy. This setting determines whether others can see meeting details, free/busy times, or just availability, helping optimize scheduling while protecting sensitive meeting information.
18
18
DISABLEDFEATURES
19
-
{"report":true,"warn":true,"remediate":false}
19
+
{"report":false,"warn":false,"remediate":false}
20
20
ADDEDCOMPONENT
21
21
{"type":"autoComplete","multiple":false,"label":"Select Sharing Level","name":"standards.calDefault.permissionLevel","options":[{"label":"Owner - The user can create, read, edit, and delete all items in the folder, and create subfolders. The user is both folder owner and folder contact.","value":"Owner"},{"label":"Publishing Editor - The user can create, read, edit, and delete all items in the folder, and create subfolders.","value":"PublishingEditor"},{"label":"Editor - The user can create items in the folder. The contents of the folder do not appear.","value":"Editor"},{"label":"Publishing Author. The user can read, create all items/subfolders. Can modify and delete only items they create.","value":"PublishingAuthor"},{"label":"Author - The user can create and read items, and modify and delete items that they create.","value":"Author"},{"label":"Non Editing Author - The user has full read access and create items. Can can delete only own items.","value":"NonEditingAuthor"},{"label":"Reviewer - The user can read all items in the folder.","value":"Reviewer"},{"label":"Contributor - The user can create items and folders.","value":"Contributor"},{"label":"Availability Only - Indicates that the user can view only free/busy time within the calendar.","value":"AvailabilityOnly"},{"label":"Limited Details - The user can view free/busy time within the calendar and the subject and location of appointments.","value":"LimitedDetails"},{"label":"None - The user has no permissions on the folder.","value":"none"}]}
22
22
IMPACT
@@ -49,70 +49,86 @@ function Invoke-CIPPStandardcalDefault {
49
49
return
50
50
}
51
51
52
-
if ($Settings.remediate-eq$true) {
53
-
$UpdateDB=$false
54
-
try {
55
-
# Get calendar permissions from cache - this contains the calendar Identity we need
Write-LogMessage-API 'Standards'-tenant $Tenant-message "Found $TotalCalendars calendars. $CalendarsToUpdate need permission update to $permissionLevel."-sev Info
74
-
75
-
if ($CalendarsToUpdate-eq0) {
76
-
Write-LogMessage-API 'Standards'-tenant $Tenant-message 'All calendars already have the correct default permission level.'-sev Info
77
-
return
78
-
}
55
+
if (-not$CalendarPermissions) {
56
+
Write-LogMessage-API 'Standards'-tenant $Tenant-message 'No cached calendar permissions found. Please ensure the mailbox cache has been populated.'-sev Error
57
+
return
58
+
}
79
59
80
-
# Set permissions for each calendar that needs updating
81
-
$SuccessCounter=0
82
-
$ErrorCounter=0
60
+
# Filter to only Default user permissions that don't match target level
Write-LogMessage-API 'Standards'-tenant $Tenant-message "Set default calendar permission for $($Calendar.Identity) to $permissionLevel"-sev Debug
93
+
$SuccessCounter++
94
+
$UpdateDB=$true
95
+
} catch {
96
+
$ErrorCounter++
97
+
$ErrorMessage=Get-CippException-Exception $_
98
+
Write-LogMessage-API 'Standards'-tenant $Tenant-message "Failed to set calendar permission for $($Calendar.Identity): $($ErrorMessage.NormalizedError)"-sev Error -LogData $ErrorMessage
90
99
}
91
-
Write-LogMessage-API 'Standards'-tenant $Tenant-message "Set default calendar permission for $($Calendar.Identity) to $permissionLevel"-sev Debug
92
-
$SuccessCounter++
93
-
$UpdateDB=$true
94
-
} catch {
95
-
$ErrorCounter++
96
-
$ErrorMessage=Get-CippException-Exception $_
97
-
Write-LogMessage-API 'Standards'-tenant $Tenant-message "Failed to set calendar permission for $($Calendar.Identity): $($ErrorMessage.NormalizedError)"-sev Error -LogData $ErrorMessage
98
100
}
99
-
}
100
101
101
-
Write-LogMessage-API 'Standards'-tenant $Tenant-message "Successfully set default calendar permissions for $SuccessCounter calendars. $ErrorCounter failed."-sev Info
102
+
Write-LogMessage-API 'Standards'-tenant $Tenant-message "Successfully set default calendar permissions for $SuccessCounter calendars. $ErrorCounter failed."-sev Info
102
103
103
-
# Refresh calendar permissions cache after remediation only if changes were made
104
-
if ($UpdateDB) {
105
-
try {
106
-
Set-CIPPDBCacheMailboxes-TenantFilter $Tenant
107
-
} catch {
108
-
Write-LogMessage-API 'Standards'-tenant $Tenant-message "Failed to refresh mailbox cache after remediation: $($_.Exception.Message)"-sev Warning
104
+
# Refresh calendar permissions cache after remediation only if changes were made
105
+
if ($UpdateDB) {
106
+
try {
107
+
Set-CIPPDBCacheMailboxes-TenantFilter $Tenant
108
+
} catch {
109
+
Write-LogMessage-API 'Standards'-tenant $Tenant-message "Failed to refresh mailbox cache after remediation: $($_.Exception.Message)"-sev Warning
110
+
}
109
111
}
112
+
} catch {
113
+
$ErrorMessage=Get-CippException-Exception $_
114
+
Write-LogMessage-API 'Standards'-tenant $Tenant-message "Could not set default calendar permissions. Error: $($ErrorMessage.NormalizedError)"-sev Error -LogData $ErrorMessage
110
115
}
116
+
}
117
+
}
111
118
112
-
} catch {
113
-
$ErrorMessage=Get-CippException-Exception $_
114
-
Write-LogMessage-API 'Standards'-tenant $Tenant-message "Could not set default calendar permissions. Error: $($ErrorMessage.NormalizedError)"-sev Error -LogData $ErrorMessage
119
+
if ($Settings.alert-eq$true) {
120
+
if ($NeedsUpdate.Count-eq0) {
121
+
Write-LogMessage-API 'Standards'-tenant $Tenant-message 'Default calendar permissions are correctly configured for all mailboxes'-sev Info
122
+
} else {
123
+
Write-StandardsAlert-message "Default calendar permission is not set to $permissionLevel for $($NeedsUpdate.Count) calendars"-object ($NeedsUpdate|Select-Object-Property Identity, AccessRights) -tenant $Tenant-standardName 'calDefault'-standardId $Settings.standardId
124
+
Write-LogMessage-API 'Standards'-tenant $Tenant-message "Default calendar permission is not set to $permissionLevel for $($NeedsUpdate.Count) calendars"-sev Info
0 commit comments