Skip to content

How to convert PSRule output to structured objects or formatted string. #1266

Answered by BernieWhite
Marc013 asked this question in Q&A
Discussion options

You must be logged in to vote

@Marc013 Thank you for the question. Yes, you can do this. An additional parameter (-ResultVariable) exists on Assert-PSRule for this reason.

For example:

[PSRule.Configuration.PSRuleOption]$psRuleOptions = New-PSRuleOption -Configuration @{ AZURE_BICEP_FILE_EXPANSION = $true }

Assert-PSRule -InputPath .\Templates\storage.bicep -Module PSRule.Rules.Azure -Format File -Outcome All -Path .\.ps-rule\ -Option $PSRuleOptions -Culture en -OutputPath .\results\__PSRuleResults.xml -OutputFormat NUnit3 -ResultVariable results

# Get results
$results

See https://microsoft.github.io/PSRule/v2/commands/PSRule/en-US/Assert-PSRule/.


I hope that answers your question.

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@Marc013
Comment options

@BernieWhite
Comment options

@Marc013
Comment options

@BernieWhite
Comment options

@Marc013
Comment options

Answer selected by Marc013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants