Skip to content

Commit a308f03

Browse files
intune deployment for Defender fixes
1 parent baddbf5 commit a308f03

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Endpoint/MEM/Invoke-AddDefenderDeployment.ps1

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,14 @@ Function Invoke-AddDefenderDeployment {
3535
iosMobileApplicationManagementEnabled = [bool]$Compliance.appSync
3636
microsoftDefenderForEndpointAttachEnabled = [bool]$true
3737
} | ConvertTo-Json -Compress
38-
$SettingsRequest = New-GraphPOSTRequest -uri 'https://graph.microsoft.com/beta/deviceManagement/mobileThreatDefenseConnectors/' -tenantid $tenant -type POST -body $SettingsObj -AsApp $true
39-
"$($Tenant): Successfully set Defender Compliance and Reporting settings"
38+
$ExistingSettings = New-GraphGETRequest -uri 'https://graph.microsoft.com/beta/deviceManagement/mobileThreatDefenseConnectors/fc780465-2017-40d4-a0c5-307022471b92' -tenantid $tenant
39+
if ($ExistingSettings) {
40+
"Defender Intune Configuration already active for $($Tenant). Skipping"
41+
} else {
42+
$SettingsRequest = New-GraphPOSTRequest -uri 'https://graph.microsoft.com/beta/deviceManagement/mobileThreatDefenseConnectors/' -tenantid $tenant -type POST -body $SettingsObj -AsApp $true
43+
"$($Tenant): Successfully set Defender Compliance and Reporting settings"
44+
}
45+
4046

4147
$Settings = switch ($PolicySettings) {
4248
{ $_.ScanArchives } {
@@ -210,7 +216,7 @@ Function Invoke-AddDefenderDeployment {
210216
settings = @($EDRSettings)
211217
}
212218
Write-Host ( $EDRbody)
213-
$CheckExististingEDR = New-GraphGETRequest -uri 'https://graph.microsoft.com/beta/deviceManagement/configurationPolicies' -tenantid $tenant | Where-Object -Property Name -eq 'EDR Configuration'
219+
$CheckExististingEDR = New-GraphGETRequest -uri 'https://graph.microsoft.com/beta/deviceManagement/configurationPolicies' -tenantid $tenant | Where-Object -Property Name -EQ 'EDR Configuration'
214220
if ('EDR Configuration' -in $CheckExististingEDR.Name) {
215221
"$($Tenant): EDR Policy already exists. Skipping"
216222
} else {

0 commit comments

Comments
 (0)