Skip to content

Invoke-PSRule -InputPath treats input as file unless it ends with [System.IO.Path]::DirectorySeparatorChar #1842

@o-l-a-v

Description

@o-l-a-v

Description of the issue

Invoke-PSRule -InputPath seems to treat input as file unless it ends with [System.IO.Path]::DirectorySeparatorChar.

To Reproduce

Inside C:\Users\olav.birkeland\some\directory I have two Bicep compiled files:

  • main.bicep
  • prod.bicepparam
Invoke-PSRule -InputPath 'C:\Users\olav.birkeland\some\directory' -Module 'PSRule.Rules.Azure' -Format 'File' -Outcome 'Fail','Error' -OutputFormat 'None' -Debug

Gives DEBUG: Target failed If precondition. Without debug it gives no output. While:

Invoke-PSRule -InputPath 'C:\Users\olav.birkeland\some\directory\' -Module 'PSRule.Rules.Azure' -Format 'File' -Outcome 'Fail','Error'

gives

RuleName                            Outcome    Recommendation
--------                            -------    --------------
Azure.Template.UseDescriptions      Fail       Specify descriptions for each resource in the template.

Expected behaviour

Detect whether -InputPath is a file or a directory. For instance [System.IO.File]::Exist('C:\Users\olav.birkeland\some\directory') returns $false.

Error output


Module in use and version:

  • PSRule v2.9.0
  • PSRule.Rules.Azure v1.36.0

Captured output from $PSVersionTable:

Name                           Value
----                           -----
PSVersion                      7.4.2
PSEdition                      Core
GitCommitId                    7.4.2
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Additional context

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfeature: inputIssues that affect input

Type

No fields configured for Bug.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions