Skip to content

Improve Usability of PSScriptAnalyzer.psd1 #2102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
cawoodm opened this issue May 8, 2025 · 1 comment
Open

Improve Usability of PSScriptAnalyzer.psd1 #2102

cawoodm opened this issue May 8, 2025 · 1 comment

Comments

@cawoodm
Copy link

cawoodm commented May 8, 2025

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

@cawoodm
Copy link
Author

cawoodm commented May 8, 2025

Also, trying to install the latest version 1.24 does not work.

$ Install-Module -Name PSScriptAnalyzer -Force -MinimumVersion 1.24

$Get-Module PSScriptAnalyzer

ModuleType Version    PreRelease Name                 
---------- -------    ---------- ----                           
Script     1.23.0                PSScriptAnalyzer            

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant