> ## Documentation Index
> Fetch the complete documentation index at: https://tally.wharflab.com/llms.txt
> Use this file to discover all available pages before exploring further.

# powershell/PSUseToExportFieldsInManifest

> Use the *ToExport module manifest fields.

`powershell/PSUseToExportFieldsInManifest` is a PSScriptAnalyzer diagnostic emitted by tally for PowerShell snippets embedded in Dockerfiles.

| Property | Value             |
| -------- | ----------------- |
| Severity | Warning           |
| Category | PSScriptAnalyzer  |
| Default  | Disabled in tally |
| Auto-fix | No                |

<Note>
  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`.
</Note>

## 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

```powershell theme={null}
FunctionsToExport = $null
```

### Correct code

```powershell theme={null}
FunctionsToExport = @()
```

## Example 2

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

### Problematic code

```powershell theme={null}
FunctionsToExport = '*'
```

### Correct code

```powershell theme={null}
FunctionsToExport = @(Get-Foo, Set-Foo)
```

## Source

This rule documentation is adapted from Microsoft's PSScriptAnalyzer documentation for
[UseToExportFieldsInManifest](https://github.com/MicrosoftDocs/PowerShell-Docs-Modules/blob/main/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseToExportFieldsInManifest.md),
licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).
