Skip to content

🪲 MT.1024 Not parsing recommendations correctly for tests #1431

@CrookedJ

Description

@CrookedJ

Describe the bug

The Entra recommendations tests are not executed due to the result of the graph request being parsed incorrectly. This results in a failed test that is malformed.

To Reproduce

Steps to reproduce the behavior:

  1. Execute Invoke-Maester -Path .\Maester\Entra\ -Tag Recommendation
  2. Results show one malformed (ID-less) test has failed

Module Version

2.0.0

Environment Data

Name                           Value
----                           -----
PSVersion                      7.5.4
PSEdition                      Core
GitCommitId                    7.5.4
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Screenshots

Image Image

Additional context

The graph request in .\Maester\Entra\Test-EntraRecommendations.Tests.ps1 to retrieve the recommendations is $EntraRecommendations = Invoke-MtGraphRequest -DisableCache -ApiVersion beta -RelativeUri 'directory/recommendations?$expand=impactedResources' -OutputType Hashtable

This results in $EntraRecommendations containing a hashtable like

Name                           Value
----                           -----
value                          {0064a2ca-615a-4bca-9351-d2b35242dc12_aadGraphDeprecationServicePrincipal, 0064a2ca-615a-
@odata.context                 https://graph.microsoft.com/beta/$metadata#directory/recommendations(impactedResources())

Yet the test attempts to loop through that hashtable and reference non-existent properties

<#..snip..#> -ForEach $EntraRecommendations {
$RecommendationId = $_.id`

Modifying it to -ForEach $EntraRecommendations.value { so it loops through them correctly does work, but the resulting IDs seem wrong. I'm unsure of what the correct IDs are.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions