API Reference
Get-MissingFunctions
Analyzes a script or scriptblock and reports functions/commands it calls that are not present.
Remarks
This cmdlet parses PowerShell code and returns a list of referenced commands that look like missing local helpers. It is useful when building “portable” scripts/modules where you want to detect (and optionally inline) helper functions. When -ApprovedModules is specified, helper definitions are only accepted from those modules.
Examples
List missing function dependencies for a script
PS>
Get-MissingFunctions -FilePath '.\Build\Build-Module.ps1' -Summary
Returns a list of functions referenced by the script that are not part of the script itself.
Analyze a scriptblock and return inlineable helper definitions
PS>
$sb = { Invoke-ModuleBuild -ModuleName 'MyModule' }; Get-MissingFunctions -Code $sb -SummaryWithCommands -ApprovedModules 'PSSharedGoods','PSPublishModule'
Returns a structured report that can include helper function bodies sourced from approved modules.
Common Parameters
This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
For more information, see about_CommonParameters.
Syntax
Get-MissingFunctions [-ApprovedModules <String[]>] [-FilePath <String>] [-Functions <String[]>] [-IgnoreFunctions <String[]>] [-Summary] [-SummaryWithCommands] [<CommonParameters>]
#
FileParameters
- ApprovedModules String[]
- Module names that are allowed sources for pulling inline helper function definitions.
- FilePath String
- Path to a script file to analyze for missing function dependencies. Alias: Path.
- Functions String[]
- Known function names to treat as already available (exclude from missing list).
- IgnoreFunctions String[]
- Function names to ignore when computing the missing set.
- Summary SwitchParameter
- Return only a flattened summary list of functions used (objects with Name/Source), not inlined definitions.
- SummaryWithCommands SwitchParameter
- Return a typed report with Summary, SummaryFiltered, and Functions.
Outputs
System.Object
Get-MissingFunctions [-ApprovedModules <String[]>] [-Code <ScriptBlock>] [-Functions <String[]>] [-IgnoreFunctions <String[]>] [-Summary] [-SummaryWithCommands] [<CommonParameters>]
#
CodeParameters
- ApprovedModules String[]
- Module names that are allowed sources for pulling inline helper function definitions.
- Code ScriptBlock
- ScriptBlock to analyze instead of a file. Alias: ScriptBlock.
- Functions String[]
- Known function names to treat as already available (exclude from missing list).
- IgnoreFunctions String[]
- Function names to ignore when computing the missing set.
- Summary SwitchParameter
- Return only a flattened summary list of functions used (objects with Name/Source), not inlined definitions.
- SummaryWithCommands SwitchParameter
- Return a typed report with Summary, SummaryFiltered, and Functions.
Outputs
System.Object