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

FIX: Ensure '$definition' is Hashtable in 'Format-PolicyDefinition' #466

Merged
merged 1 commit into from
Sep 2, 2024

Conversation

aschabus
Copy link
Collaborator

This pull request includes a significant change to the Format-PolicyDefinition function in the Scripts/Format-PolicyDefinition.ps1 file. The primary focus is on improving error handling and ensuring the JSON content is correctly parsed.

Key changes include:

  • Added a try-catch block to handle exceptions when converting JSON content, ensuring any errors are caught and their messages are thrown. (Scripts/Format-PolicyDefinition.ps1)
  • Restored the use of ConvertFrom-Json with -AsHashtable and -Depth 100 to handle the JSON conversion more robustly. (Scripts/Format-PolicyDefinition.ps1)table, we cannot remove keys one by one, causing the script to fail.

If '$definition' isn't a hashtable, we cannot remove keys one by one, causing the script to fail.
@aschabus aschabus requested a review from neiichango August 21, 2024 15:18
Copy link
Collaborator

@Joshua-Donovan Joshua-Donovan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed code and the try catch addition does not appear to cause issues.

Downloaded the script and ran it several times with test policy definitions to validate it is working as expected. I had no unexpected errors in my testing.

@Joshua-Donovan Joshua-Donovan removed the request for review from neiichango September 1, 2024 22:10
@aschabus aschabus merged commit 2d4a5ee into main Sep 2, 2024
2 checks passed
@aschabus aschabus deleted the fix/format-policydefinition branch September 2, 2024 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants