liveBook · Manning

Helper function

As explained in Practical Automation with PowerShell: Effective scripting from the console to the cloud

A helper function is a supporting function called by other functions to perform a reusable internal operation.

A helper function performs a reusable internal operation for other functions in a PowerShell module. A shared data-parsing function, for example, can support several public functions without becoming a user-facing command. section 2.2.3

Organize helper functions so module users see only the operations they need:

  • Place helper-function files in a Private folder and public commands in a Public folder to make their intended roles clear. section 2.2.3
  • Update the module's psm1 file to import functions from the Private folder as well as the Public folder. section 2.2.3
  • Exclude helper functions from the psd1 manifest's exported-function list; folder names organize files but do not hide commands by themselves. section 2.2.3
FunctionsToExport = 'Remove-ArchivedFiles', 'Set-ArchiveFilePath'

Use an explicit FunctionsToExport list to expose public commands while leaving helper functions unavailable as exported module commands. section 2.2.3

How Practical Automation with PowerShell: Effective scripting from the console to the cloud covers it

How deep it goes
Explains helper-function placement, importing, and manifest exclusion, but stops short of implementing a complete helper function.
Examples
Uses a shared data-parsing function and Public and Private folders to illustrate reusable internal module logic.
What it assumes
Assumes familiarity with PowerShell modules and manifests while clarifying how internal functions are organized and excluded.
What you can do after
Operate/configure PowerShell module exports by separating helper files and delisting private functions from the manifest.
How it connects
Connects helper functions with public functions, PowerShell modules, psm1 files, and psd1 manifests.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Practical Automation with PowerShell: Effective scripting from the console to the cloud. The section links point to the parts of the book it draws on.