PowerShell / PowerShell/PSScriptAnalyzer

Improve Usability of PSScriptAnalyzer.psd1

Open
#2,102 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
2.2k
Forks
414
Avg merge
13h 1m
Merged PRs (30d)
2

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with PSScriptAnalyzer.psd1 and the AvoidUsingCmdletAliases documentation linked in the issue. Reproduce the failure by adding the Rules member and running Import-Module PSScriptAnalyzer. Done means the documented rule configuration can be used without the manifest-invalid-members error.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.