|
| 1 | +function Invoke-CippTestZTNA24839 { |
| 2 | + param($Tenant) |
| 3 | + |
| 4 | + $TestId = 'ZTNA24839' |
| 5 | + |
| 6 | + try { |
| 7 | + $DeviceConfigs = New-CIPPDbRequest -TenantFilter $Tenant -Type 'IntuneDeviceConfigurations' |
| 8 | + |
| 9 | + if (-not $DeviceConfigs) { |
| 10 | + Add-CippTestResult -TenantFilter $Tenant -TestId $TestId -TestType 'Devices' -Status 'Investigate' -ResultMarkdown 'Device configurations not found in database' -Risk 'High' -Name 'Secure Wi-Fi profiles protect iOS devices from unauthorized network access' -UserImpact 'Low' -ImplementationEffort 'Medium' -Category 'Data' |
| 11 | + return |
| 12 | + } |
| 13 | + |
| 14 | + $iOSWifiConfProfiles = @($DeviceConfigs | Where-Object { $_.'@odata.type' -eq '#microsoft.graph.iosWiFiConfiguration' }) |
| 15 | + $CompliantIosWifiConfProfiles = @($iOSWifiConfProfiles | Where-Object { $_.wiFiSecurityType -in @('wpa2Enterprise', 'wpaEnterprise') }) |
| 16 | + $AssignedCompliantProfiles = @($CompliantIosWifiConfProfiles | Where-Object { $_.assignments -and $_.assignments.Count -gt 0 }) |
| 17 | + $Passed = $AssignedCompliantProfiles.Count -gt 0 |
| 18 | + |
| 19 | + if ($Passed) { |
| 20 | + $ResultMarkdown = "✅ At least one Enterprise Wi-Fi profile for iOS exists and is assigned.`n`n" |
| 21 | + } else { |
| 22 | + $ResultMarkdown = "❌ No Enterprise Wi-Fi profile for iOS exists or none are assigned.`n`n" |
| 23 | + } |
| 24 | + |
| 25 | + if ($iOSWifiConfProfiles.Count -gt 0) { |
| 26 | + $ResultMarkdown += "## iOS WiFi Configuration Profiles`n`n" |
| 27 | + $ResultMarkdown += "| Policy Name | Wi-Fi Security Type | Assigned |`n" |
| 28 | + $ResultMarkdown += "| :---------- | :------------------ | :------- |`n" |
| 29 | + |
| 30 | + foreach ($policy in $iOSWifiConfProfiles) { |
| 31 | + $securityType = if ($policy.wiFiSecurityType) { $policy.wiFiSecurityType } else { 'Unknown' } |
| 32 | + $assigned = if ($policy.assignments -and $policy.assignments.Count -gt 0) { '✅ Yes' } else { '❌ No' } |
| 33 | + $ResultMarkdown += "| $($policy.displayName) | $securityType | $assigned |`n" |
| 34 | + } |
| 35 | + } else { |
| 36 | + $ResultMarkdown += "No iOS WiFi configuration profiles found.`n" |
| 37 | + } |
| 38 | + |
| 39 | + $Status = if ($Passed) { 'Passed' } else { 'Failed' } |
| 40 | + Add-CippTestResult -TenantFilter $Tenant -TestId $TestId -TestType 'Devices' -Status $Status -ResultMarkdown $ResultMarkdown -Risk 'High' -Name 'Secure Wi-Fi profiles protect iOS devices from unauthorized network access' -UserImpact 'Low' -ImplementationEffort 'Medium' -Category 'Data' |
| 41 | + |
| 42 | + } catch { |
| 43 | + $ErrorMessage = Get-CippException -Exception $_ |
| 44 | + Write-LogMessage -API 'Tests' -tenant $Tenant -message "Failed to run test: $($ErrorMessage.NormalizedError)" -sev Error -LogData $ErrorMessage |
| 45 | + Add-CippTestResult -TenantFilter $Tenant -TestId $TestId -TestType 'Devices' -Status 'Failed' -ResultMarkdown "Error running test: $($ErrorMessage.NormalizedError)" -Risk 'High' -Name 'Secure Wi-Fi profiles protect iOS devices from unauthorized network access' -UserImpact 'Low' -ImplementationEffort 'Medium' -Category 'Data' |
| 46 | + } |
| 47 | +} |
0 commit comments