Skip to main content
powershell/PSUseToExportFieldsInManifest is a PSScriptAnalyzer diagnostic emitted by tally for PowerShell snippets embedded in Dockerfiles.
tally disables this rule by default because Dockerfiles do not ship PowerShell module manifests (.psd1 files) — this rule targets module-authoring artifacts that are out of scope for container builds. Re-enable it with include = ["powershell/PSUseToExportFieldsInManifest"] or by setting rules.powershell.PSUseToExportFieldsInManifest.severity = "warning" in .tally.toml.

Description

To improve the performance of module auto-discovery, module manifests should not use wildcards ('*') or null ($null) in the following entries:
  • AliasesToExport
  • CmdletsToExport
  • FunctionsToExport
  • VariablesToExport
Using wildcards or null causes PowerShell to perform expensive work to analyze a module during module auto-discovery.

How

Use an explicit list in the entries.

Example 1

Suppose there are no functions in your module to export. Then,

Problematic code

Correct code

Example 2

Suppose there are only two functions in your module, Get-Foo and Set-Foo that you want to export. Then,

Problematic code

Correct code

Source

This rule documentation is adapted from Microsoft’s PSScriptAnalyzer documentation for UseToExportFieldsInManifest, licensed under CC BY 4.0.