Skip to content

Rule not finding field in JSON Configuration #2786

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

You must be logged in to vote

If you're using PSRule v2.9.0, then try adding -Format Json to the end of your Assert-PSRule command line.

The reason is because you are piping a file object to Assert-PSRule, and by default it's going to look at and analyze the file object instead of the content of the file. Since the file object doesn't have that property the rule failed as expected.

Also, you can simplify this if you want by removing the Get-ChildItem part.

e.g.

Assert-PSRule -Path .\file_path\test.datacenter.Rule.yaml -InputPath .\file_path\**\*.json -Format Json

Also noting there is changes to how this works in v3 which is preview, so if you are developing something new, be aware of these changes so you can avoid re…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@BernieWhite
Comment options

Answer selected by sapritchard
@sapritchard
Comment options

@sapritchard
Comment options

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