Skip to content

Commit

Permalink
Merge pull request #280 from tdcthosc/Enhance-MT.1024-Entra-Recommend…
Browse files Browse the repository at this point in the history
…ations

Enhance mt.1024 entra recommendations
  • Loading branch information
merill authored Jul 1, 2024
2 parents 5e6dce3 + 20bbbb2 commit 5f808f8
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions tests/Maester/Entra/Test-EntraRecommendations.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
BeforeDiscovery {
$EntraIDPlan = Get-MtLicenseInformation -Product "EntraID"
$EntraRecommendations = Invoke-MtGraphRequest -DisableCache -ApiVersion beta -RelativeUri 'directory/recommendations' -OutputType Hashtable
$EntraRecommendations = Invoke-MtGraphRequest -DisableCache -ApiVersion beta -RelativeUri 'directory/recommendations?$expand=impactedResources' -OutputType Hashtable
Write-Verbose "Found $($EntraRecommendations.Count) Entra recommendations"
}

Describe "Entra Recommendations" -Tag "Entra", "Security", "All", "Recommendation" -ForEach $EntraRecommendations {
It "MT.1024: Entra Recommendation - <displayName>. See https://maester.dev/docs/tests/MT.1024" -Tag "MT.1024" {
#region Add detailed test description
$ActionSteps = $actionSteps | Sort-Object -Property 'stepNumber' | Select-Object -ExpandProperty text -EA SilentlyContinue
$ActionSteps = $actionSteps | Sort-Object -Property 'stepNumber' | ForEach-Object {
$_.text + "[$($_.actionUrl.displayName)]($($_.actionUrl.url))."
}
$ActionSteps = $ActionSteps -join "`n`n"
$ResultMarkdown = $insights + "`n`nRemediation actions:`n`n" + $ActionSteps
if ($status -ne 'completedBySystem' -and $impactedResources) {
$impactedResourcesList = "`n`n#### Impacted resources`n`n | Status | Name | First detected| `n"
$impactedResourcesList += "| --- | --- | --- |`n"
foreach ($resource in $impactedResources) {
if ($resource.status -eq 'completedBySystem') {
$resourceResult = "✅ Pass"
} else {
$resourceResult = "❌ Fail"
}
$impactedResourcesList += "| $($resourceResult) | [$($resource.displayName)]($($resource.portalUrl)) | $($resource.addedDateTime) | `n"
}
}
$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 5f808f8

Please sign in to comment.