Possible to suppress PSRule output in terminal completely and output as a JSON-file #1863
-
Hi, I have a scenario where I want to use Pester to test some functionality in PSRule, and therefore I need the output as JSON. Using variables, Out-Null doesn't work either. My only solution is to start the job in a separate thread using "Start-Job". Any hints? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @lassehastrup, Thanks for the question. For integrating with PowerShell tools try Invoke-PSRule.
PSRule for Azure has a number of examples of this. See: https://github.com/Azure/PSRule.Rules.Azure/blob/main/tests/PSRule.Rules.Azure.Tests/Azure.ACR.Tests.ps1 Also note there is a few deprecations for the future v3 release to be aware of: https://microsoft.github.io/PSRule/v3/deprecations/ I hope that answers the question. |
Beta Was this translation helpful? Give feedback.
Hi @lassehastrup, Thanks for the question. For integrating with PowerShell tools try Invoke-PSRule.
Assert-PSRule
is intended to provide a CI/CD friendly output to pipelines as text.Invoke-PSRule
will output native PowerShell objects that can be tested with Pester. It accepts almost identical parameters and supportsps-rule.yaml
same asAssert-PSRule
.PSRule for Azure has a number of examples of this. See: https://github.com/Azure/PSRule.Rules.Azure/blob/main/tests/PSRule.Rules.Azure.Tests/Azure.ACR.Tests.ps1
Also note there is a few deprecations for the future v3 release to be aware of: https://microsoft.github.io/PSRule/v3/deprecations/
I hope that answers the question.