Skip to content

Commit

Permalink
Merge pull request #11 from KelvinTegelaar/master
Browse files Browse the repository at this point in the history
[pull] master from KelvinTegelaar:master
  • Loading branch information
pull[bot] authored Dec 11, 2023
2 parents ce782cf + 2494cc2 commit e8d0f31
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Function Invoke-AddStandardsDeploy {

try {
$Tenants = ($Request.body | Select-Object Select_*).psobject.properties.value
$Settings = ($request.body | Select-Object -Property *, 'v2' -ExcludeProperty Select_*, None )
$Settings.v2 = $true
$Settings = ($request.body | Select-Object -Property *, v2* -ExcludeProperty Select_*, None )
$Settings | Add-Member -NotePropertyName 'v2.1' -NotePropertyValue $true -Force
foreach ($Tenant in $tenants) {

$object = [PSCustomObject]@{
Expand All @@ -37,8 +37,7 @@ Function Invoke-AddStandardsDeploy {
}
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Successfully added standards deployment' -Sev 'Info'
$body = [pscustomobject]@{'Results' = 'Successfully added standards deployment' }
}
catch {
} catch {
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Standards API failed. Error:$($_.Exception.Message)" -Sev 'Error'
$body = [pscustomobject]@{'Results' = "Failed to add standard: $($_.Exception.Message)" }
}
Expand Down
13 changes: 9 additions & 4 deletions Modules/CIPPCore/Public/Invoke-CIPPStandardsRun.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function Invoke-CIPPStandardsRun {
$Tenants = (Get-CIPPAzDataTableEntity @Table -Filter $Filter).JSON | ConvertFrom-Json

#Migrate from old standards to new standards.
$Tenants | Where-Object -Property 'v2' -NE $true | ForEach-Object {
$Tenants | Where-Object -Property 'v2.1' -NE $true | ForEach-Object {
$OldStd = $_
$OldStd.standards.psobject.properties.name | ForEach-Object {
if ($_ -eq 'MailContacts') {
Expand All @@ -28,10 +28,15 @@ function Invoke-CIPPStandardsRun {
remediate = $true
}
} else {
$OldStd.Standards.$_ | Add-Member -NotePropertyName 'remediate' -NotePropertyValue $true
if ($OldStd.Standards.$_ -eq $true) {
$OldStd.Standards.$_ = @{ remediate = $true }
} else {
$OldStd.Standards.$_ | Add-Member -NotePropertyName 'remediate' -NotePropertyValue $true -Force
}

}
}
$OldStd | Add-Member -NotePropertyName 'v2' -NotePropertyValue $true -PassThru -Force
$OldStd | Add-Member -NotePropertyName 'v2.1' -NotePropertyValue $true -PassThru -Force
$Entity = @{
PartitionKey = 'standards'
RowKey = "$($OldStd.Tenant)"
Expand Down Expand Up @@ -73,7 +78,7 @@ function Invoke-CIPPStandardsRun {

#For each item in our object, run the queue.

foreach ($task in $object | Where-Object -Property Standard -NE 'v2') {
foreach ($task in $object | Where-Object -Property Standard -NotLike 'v2*') {
$QueueItem = [pscustomobject]@{
Tenant = $task.Tenant
Standard = $task.Standard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ function Invoke-CIPPStandardcalDefault {
$Mailboxes = New-ExoRequest -tenantid $Tenant -cmdlet 'get-mailbox'
foreach ($Mailbox in $Mailboxes) {
try {
New-ExoRequest -tenantid $Tenant -cmdlet 'Get-MailboxFolderStatistics' -cmdParams @{identity = $Mailbox.UserPrincipalName; FolderScope = 'Calendar' } -Anchor $Mailbox.UserPrincipalName | ForEach-Object {
New-ExoRequest -tenantid $Tenant -cmdlet 'Set-MailboxFolderPermission' -cmdparams @{Identity = ($_.identity).replace('\', ':\'); User = 'Default'; AccessRights = $Settings.permissionlevel } -Anchor $Mailbox.UserPrincipalName
Write-LogMessage -API 'Standards' -tenant $tenant -message "Set default folder permission for $($Mailbox.UserPrincipalName) to $($Settings.permissionlevel)" -sev Error

New-ExoRequest -tenantid $Tenant -cmdlet 'Get-MailboxFolderStatistics' -cmdParams @{identity = $Mailbox.UserPrincipalName; FolderScope = 'Calendar' } -Anchor $Mailbox.UserPrincipalName | Where-Object { $_.FolderType -eq 'Calendar' } | ForEach-Object {
New-ExoRequest -tenantid $Tenant -cmdlet 'Set-MailboxFolderPermission' -cmdparams @{Identity = "$($Mailbox.UserPrincipalName):$($_.FolderId)"; User = 'Default'; AccessRights = $setting.permissionlevel } -Anchor $Mailbox.UserPrincipalName
Write-LogMessage -API 'Standards' -tenant $tenant -message "Set default folder permission for $($Mailbox.UserPrincipalName):\$($_.Name) to $($setting.permissionlevel)" -sev Error
}
} catch {
Write-LogMessage -API 'Standards' -tenant $tenant -message "Could not set default calendar permissions. Error: $($_.exception.message)" -sev Error
}

catch {
Write-LogMessage -API 'Standards' -tenant $tenant -message "Could not set default calendar permissions for $($Mailbox.UserPrincipalName). Error: $($_.exception.message)" -sev Error
}

}
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Done setting default calendar permissions.' -sev Info

Expand Down
2 changes: 1 addition & 1 deletion version_latest.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.8.0
4.8.2

0 comments on commit e8d0f31

Please sign in to comment.