Skip to content

VS Code - PSScriptAnalyzer Highlighting #1005

@Mcgurk125

Description

@Mcgurk125

Hi all,

I am in the process of writing up custom rules to invoke my company style guide. To begin with I have written a simple function that appears to work correctly when running Invoke-ScriptAnalyzer, returning a Diagnostic Record[].

Does anyone have a guide on implementing custom rules in VSCode? Ideally it will automatically highlight code that does not conform to both the built in script analyzer rules and the custom ones defined.

I have attempted to update the PSScriptAnalyzerSettings.psd1 (and ensured powershell.scriptAnalysis.settingsPath points to that file) with the following:

@{
    # I have changed the path below for privacy 
    CustomRulePath="\\mydomain\blah\blah\blah\blah\blah\PowershellScriptAnalyzer"
    IncludeDefaultRules=$true
    RecurseCustomRulePath = $true
    ExcludeRules = @(
        'PSAvoidUsingWriteHost',
        'PSUseShouldProcessForStateChangingFunctions',
        'PSUseOutputTypeCorrectly'
    )
}

Any ideas?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions