Skip to content

Commit

Permalink
Split PR maester365#555 dismissed Entra Recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
weyCC81 committed Dec 8, 2024
1 parent a5910b9 commit 9fcb29a
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions tests/Maester/Entra/Test-EntraRecommendations.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
BeforeDiscovery {
$EntraRecommendations = Invoke-MtGraphRequest -DisableCache -ApiVersion beta -RelativeUri 'directory/recommendations?$expand=impactedResources' -OutputType Hashtable
Write-Verbose "Found $($EntraRecommendations.Count) Entra recommendations"
try {
$EntraRecommendations = Invoke-MtGraphRequest -DisableCache -ApiVersion beta -RelativeUri 'directory/recommendations?$expand=impactedResources' -OutputType Hashtable
Write-Verbose "Found $($EntraRecommendations.Count) Entra recommendations"
} catch {
Write-Verbose "Authentication needed. Please call Connect-MgGraph."
}
}

Describe "Entra Recommendations" -Tag "Maester", "Entra", "Security", "All", "Recommendation" -ForEach $EntraRecommendations {
It "MT.1024: Entra Recommendation - <displayName>. See https://maester.dev/docs/tests/MT.1024" -Tag "MT.1024", $recommendationType {
$EntraIDPlan = Get-MtLicenseInformation -Product "EntraID"

$EntraPremiumRecommendations = @(
"insiderRiskPolicy",
"userRiskPolicy",
"signinRiskPolicy"
)
$EntraIDPlan = Get-MtLicenseInformation -Product "EntraID"
if ( $EntraIDPlan -ne "P2" ) {
$EntraPremiumRecommendations | ForEach-Object {
if ( $id -match "$($_)$" ) {
Expand All @@ -19,6 +24,12 @@ Describe "Entra Recommendations" -Tag "Maester", "Entra", "Security", "All", "Re
}
}
}

if ( $status -match "dismissed" ) {
Add-MtTestResultDetail -SkippedBecause Custom -SkippedCustomReason "Status:Dismissed for '$($id)'"
return $null
}

#region Add detailed test description
$ActionSteps = $actionSteps | Sort-Object -Property 'stepNumber' | ForEach-Object {
$_.text + "[$($_.actionUrl.displayName)]($($_.actionUrl.url))."
Expand All @@ -36,7 +47,7 @@ Describe "Entra Recommendations" -Tag "Maester", "Entra", "Security", "All", "Re
$impactedResourcesList += "| $($resourceResult) | [$($resource.displayName)]($($resource.portalUrl)) | $($resource.addedDateTime) | `n"
}
}
$ResultMarkdown = $insights + $impactedResourcesList + "`n`n#### Remediation actions:`n`n" + $ActionSteps + "`n`n ExcludeTag: $($recommendationType)"
$ResultMarkdown = $insights + $impactedResourcesList + "`n`n#### Remediation actions:`n`n" + $ActionSteps
Add-MtTestResultDetail -Description $benefits -Result $ResultMarkdown
#endregion
# Actual test
Expand Down

0 comments on commit 9fcb29a

Please sign in to comment.