Skip to content

Commit 0b7def3

Browse files
fix reporting
1 parent c3204ee commit 0b7def3

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardDefaultSharingLink.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ function Invoke-CIPPStandardDefaultSharingLink {
4343
$DesiredSharingLinkTypeValue = $SharingLinkTypeMap[$DesiredSharingLinkType]
4444

4545
$CurrentState = Get-CIPPSPOTenant -TenantFilter $Tenant |
46-
Select-Object -Property _ObjectIdentity_, TenantFilter, DefaultSharingLinkType, DefaultLinkPermission
46+
Select-Object -Property _ObjectIdentity_, TenantFilter, DefaultSharingLinkType, DefaultLinkPermission
4747

4848
# Check if the current state matches the desired configuration
4949
$StateIsCorrect = ($CurrentState.DefaultSharingLinkType -eq $DesiredSharingLinkTypeValue) -and ($CurrentState.DefaultLinkPermission -eq 1)
50-
50+
Write-Host "currentstate: $($CurrentState.DefaultSharingLinkType), $($CurrentState.DefaultLinkPermission). Desired: $DesiredSharingLinkTypeValue, 1"
5151
if ($Settings.remediate -eq $true) {
5252
if ($StateIsCorrect -eq $true) {
5353
Write-LogMessage -API 'Standards' -Tenant $Tenant -Message "Default sharing link settings are already configured correctly (Type: $DesiredSharingLinkType, Permission: View)" -Sev Info

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardTransportRuleTemplate.ps1

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,16 @@ function Invoke-CIPPStandardTransportRuleTemplate {
2727
#>
2828
param($Tenant, $Settings)
2929
##$Rerun -Type Standard -Tenant $Tenant -Settings $Settings 'TransportRuleTemplate'
30-
31-
If ($Settings.remediate -eq $true) {
30+
$existingRules = New-ExoRequest -ErrorAction SilentlyContinue -tenantid $Tenant -cmdlet 'Get-TransportRule' -useSystemMailbox $true
31+
if ($Settings.remediate -eq $true) {
3232
Write-Host "Settings: $($Settings | ConvertTo-Json)"
3333
$Settings.transportRuleTemplate ? ($Settings | Add-Member -NotePropertyName 'TemplateList' -NotePropertyValue $Settings.transportRuleTemplate) : $null
3434
foreach ($Template in $Settings.TemplateList) {
3535
Write-Host "working on $($Template.value)"
3636
$Table = Get-CippTable -tablename 'templates'
3737
$Filter = "PartitionKey eq 'TransportTemplate' and RowKey eq '$($Template.value)'"
3838
$RequestParams = (Get-AzDataTableEntity @Table -Filter $Filter).JSON | ConvertFrom-Json
39-
$Existing = New-ExoRequest -ErrorAction SilentlyContinue -tenantid $Tenant -cmdlet 'Get-TransportRule' -useSystemMailbox $true | Where-Object -Property Identity -EQ $RequestParams.name
40-
39+
$Existing = $existingRules | Where-Object -Property Identity -EQ $RequestParams.name
4140

4241
try {
4342
if ($Existing) {
@@ -58,4 +57,21 @@ function Invoke-CIPPStandardTransportRuleTemplate {
5857
}
5958
}
6059
}
60+
if ($Settings.report -eq $true) {
61+
$rules = $Settings.transportRuleTemplate.JSON | ConvertFrom-Json -Depth 10
62+
$MissingRules = foreach ($rule in $rules) {
63+
$CheckExististing = $existingRules | Where-Object -Property identity -EQ $rule.displayname
64+
if (!$CheckExististing) {
65+
$rule.displayname
66+
}
67+
}
68+
69+
if ($MissingRules.Count -eq 0) {
70+
$fieldValue = $true
71+
} else {
72+
$fieldValue = $MissingRules -join ', '
73+
}
74+
75+
Set-CIPPStandardsCompareField -FieldName 'standards.TransportRuleTemplate' -FieldValue $fieldValue -Tenant $Tenant
76+
}
6177
}

0 commit comments

Comments
 (0)