-
Notifications
You must be signed in to change notification settings - Fork 5.4k
/
Copy pathGet-CIPPAlertNoCAConfig.ps1
27 lines (25 loc) · 1.04 KB
/
Get-CIPPAlertNoCAConfig.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function Get-CIPPAlertNoCAConfig {
<#
.FUNCTIONALITY
Entrypoint
#>
[CmdletBinding()]
Param (
[Parameter(Mandatory = $false)]
[Alias('input')]
$InputValue,
$TenantFilter
)
try {
$CAAvailable = (New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/subscribedSkus' -tenantid $TenantFilter -ErrorAction Stop).serviceplans
if ('AAD_PREMIUM' -in $CAAvailable.servicePlanName) {
$CAPolicies = (New-GraphGetRequest -uri 'https://graph.microsoft.com/v1.0/identity/conditionalAccess/policies' -tenantid $TenantFilter)
if (!$CAPolicies.id) {
$AlertData = 'Conditional Access is available, but no policies could be found.'
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $AlertData
}
}
} catch {
Write-AlertMessage -tenant $($TenantFilter) -message "Conditional Access Config Alert: Error occurred: $(Get-NormalizedError -message $_.Exception.message)"
}
}