File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tenant/Standards Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,21 @@ function Invoke-ExecUpdateDriftDeviation {
72
72
Write-LogMessage - tenant $TenantFilter - user $request.headers .' x-ms-client-principal' - API $APINAME - message " Scheduled drift remediation task for $Setting " - Sev ' Info'
73
73
}
74
74
if ($Deviation.status -eq ' deniedDelete' ) {
75
- # Here we look at the policy ID received and the type, and nuke it.
75
+ if ($Deviation.standardName -like ' ConditionalAccessTemplate*' ) {
76
+ $ID = $Deviation.standardName -replace ' ConditionalAccessTemplates.' , ' '
77
+ Write-Host " Going to delete CA Policy with ID $ID . Deviation Name is $ ( $Deviation.standardName ) "
78
+ $null = New-GraphPostRequest - uri " https://graph.microsoft.com/v1.0/identity/conditionalAccess/policies/$ ( $ID ) " - type DELETE - tenant $TenantFilter - asapp $true
79
+ " Deleted CA Policy $ ( $ID ) "
80
+ Write-LogMessage - tenant $TenantFilter - user $request.headers .' x-ms-client-principal' - API $APINAME - message " Deleted Conditional Access Policy with ID $ ( $ID ) " - Sev ' Info'
81
+ }
82
+
83
+ if ($Deviation.standardName -like ' IntuneTemplates*' ) {
84
+ New-GraphPostRequest - uri " https://graph.microsoft.com/beta/deviceManagement/$ ( $UrlName ) ('$ ( $PolicyId ) ')" - type DELETE - tenant $TenantFilter
85
+ " Deleted Intune Policy $ ( $ID ) "
86
+ Write-LogMessage - tenant $TenantFilter - user $request.headers .' x-ms-client-principal' - API $APINAME - message " Deleted Intune Policy with ID $ ( $ID ) " - Sev ' Info'
87
+
88
+ }
89
+
76
90
}
77
91
} catch {
78
92
[PSCustomObject ]@ {
You can’t perform that action at this time.
0 commit comments