Skip to content

Improve Usability of PSScriptAnalyzer.psd1 #2102

Open
@cawoodm

Description

@cawoodm

Summary of the new feature
According to the docs it's as simple as adding rules to the Rules HashMap in PSScriptAnalyzer.psd1:

PSScriptAnalyzer.psd1

@{

  Rules             = @{
    'PSAvoidUsingCmdletAliases' = @{
      'allowlist' = @('cd', 'cls', 'copy', 'cp'')
    }
  }

  # Author of this module
  Author            = 'Microsoft Corporation'
...

Followed by running:

Import-Module PSScriptAnalyzer

However, in practice this does not work at all:

Import-Module: The '...\ms-vscode.powershell-2025.0.0\modules\PSScriptAnalyzer\1.23.0\PSScriptAnalyzer.psd1' module cannot be imported because its manifest contains one or more members that are not valid. The valid manifest members are ('ModuleToProcess', 'NestedModules', 'GUID', 'Author', 'CompanyName', 'Copyright', 'ModuleVersion', 'Description', 'PowerShellVersion', 'PowerShellHostName', 'PowerShellHostVersion', 'CLRVersion', 'DotNetFrameworkVersion', 'ProcessorArchitecture', 'RequiredModules', 'TypesToProcess', 'FormatsToProcess', 'ScriptsToProcess', 'PrivateData', 'RequiredAssemblies', 'ModuleList', 'FileList', 'FunctionsToExport', 'VariablesToExport', 'AliasesToExport', 'CmdletsToExport', 'DscResourcesToExport', 'CompatiblePSEditions', 'HelpInfoURI', 'RootModule', 'DefaultCommandPrefix').
Remove the members that are not valid ('Rules'), then try to import the module again.

I am sure this is just a beginners mistake and CAN work but it SHOULD JUST work.

Proposed technical implementation details (optional)

A clear and concise description of what you want to happen.

What is the latest version of PSScriptAnalyzer at the point of writing
1.24.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions