Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build-DeploymentPlans function fails when trying to builtin and custom policy sets to as exemptions #608

Closed
doenoe opened this issue May 2, 2024 · 2 comments
Assignees
Labels
bug Something isn't working investigating

Comments

@doenoe
Copy link

doenoe commented May 2, 2024

Describe the bug
When trying to add builtin or custom policy sets as exemptions via a .jsonc file as described here, the Build-DeploymentPlans function fails with the following error:

Confirm-PolicySetDefinitionUsedExists: C:\Users\user\Documents\PowerShell\Modules\EnterprisePolicyAsCode\10.2.1\internal\functions\Build-ExemptionsPlan.ps1:375:29
Line |
 375 |                              -PolicySetDefinitionsScopes $PacEnvironme …
     |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | A parameter cannot be found that matches parameter name 'PolicySetDefinitionsScopes'.

I tried to debug the error and I found that the Build-DeploymentPlans calls the Build-ExemptionPlans function, which again calls the Confirm-PolicySetDefinitionUsedExists function. The Confirm-PolicySetDefinitionUsedExists function is called with a -PolicySetDefinitionsScopes parameter which is not present in the Confirm-PolicySetDefinitionUsedExists.ps1 file, there is however a parameter present in the file with quite a similar name called PolicyDefinitionsScopes.

To Reproduce
Create a .jsonc file and add a custom or builtin policy set to exempt and run the Build-DeploymentPlans function.

Expected behavior
Build-DeploymentPlans should run without errors.

EPAC Version
10.2.1 - EnterprisePolicyAsCode
2.19.0 - Az.Accounts
0.13.1 - Az.ResourceGraph
6.16.2 - Az.Resources

@doenoe doenoe added the bug Something isn't working label May 2, 2024
@techlake techlake self-assigned this May 2, 2024
@techlake techlake mentioned this issue May 2, 2024
@techlake
Copy link
Contributor

techlake commented May 2, 2024

Fixed in v10.2.2

@techlake techlake closed this as completed May 2, 2024
@doenoe
Copy link
Author

doenoe commented May 3, 2024

The Build-DeploymentPlans function now fails on another unfound parameter:

Confirm-PolicySetDefinitionUsedExists: C:\Users\user\Documents\PowerShell\Modules\EnterprisePolicyAsCode\10.2.2\internal\functions\Build-ExemptionsPlan.ps1:401:29
Line |
 401 |                              -AllDefinitions $AllDefinitions.policyset …
     |                              ~~~~~~~~~~~~~~~
     | A parameter cannot be found that matches parameter name 'AllDefinitions'.

After changing the parameter name to 'AllDefinitions' the function results in the following error messages:


===================================================================================================
Processing Policy Assignments JSON files in folder 'Definitions/policyAssignments'
===================================================================================================
Number of Policy Assignment files = 37
Confirm-PolicySetDefinitionUsedExists: C:\Users\user\Documents\PowerShell\Modules\EnterprisePolicyAsCode\10.2.2\internal\functions\Build-AssignmentDefinitionEntry.ps1:49:17
Line |
  49 |                  -AllPolicySetDefinitions $CombinedPolicyDetails.polic …
     |                  ~~~~~~~~~~~~~~~~~~~~~~~~
     | A parameter cannot be found that matches parameter name 'AllPolicySetDefinitions'.
InvalidOperation: C:\Users\user\Documents\PowerShell\Modules\EnterprisePolicyAsCode\10.2.2\internal\functions\Build-AssignmentDefinitionEntry.ps1:82:13
Line |
  82 |              $normalizedEntry.displayName = $DefinitionEntry.displayNa …
     |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | The property 'displayName' cannot be found on this object. Verify that the property exists and can be set.
InvalidOperation: C:\Users\user\Documents\PowerShell\Modules\EnterprisePolicyAsCode\10.2.2\internal\functions\Build-AssignmentDefinitionEntry.ps1:116:13
Line |
 116 |              $normalizedEntry.assignment = @{
     |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | The property 'assignment' cannot be found on this object. Verify that the property exists and can be set.
Write-Error: C:\Users\user\Documents\PowerShell\Modules\EnterprisePolicyAsCode\10.2.2\functions\Build-DeploymentPlans.ps1:310:9
Line |
 310 |          Build-AssignmentPlan `
     |          ~~~~~~~~~~~~~~~~~~~~~~
     | Assignment definitions content errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working investigating
Projects
None yet
Development

No branches or pull requests

2 participants