Search notes:

PowerShell: module manifest file

A PowerShell module manifest file is a text file with the extension .psd1 that contains a hash table which contains information about a module.
Module manifests are optional for single .psm1 files or simple binary modules, however, they're required to export assemblies into the Global Assembly Cache (GAC) or for modules that support the updatable help feature.

Keys of the hash table

Key name Data type Description/comment Value assigned with new-moduleManifest
RootModule array Script module or binary module file associated with this manifest.
ModuleVersion string The value of ModuleVersion must be convertible to a System.Version object. '1.0'
CompatiblePSEditions array Supported PSEditions n/a
GUID string The GUID that uniquely identifies this module 'eb260a8d-7fe9-49fa-b79d-4ad15ad55175'
Author string Module's autor 'René'
CompanyName string Company or vendor of this module 'Unknown'
Copyright string Copyright statement for this module '(c) 2020 René. All rights reserved.'
Description string Description of the functionality provided by this module ''
PowerShellVersion string Minimum version of the Windows PowerShell engine required n/a
PowerShellHostName string Name of required Windows PowerShell host n/a
PowerShellHostVersion string Minimum version of Windows PowerShell host required n/a
DotNetFrameworkVersion string Minimum version of .NET Framework required. Valid for Desktop edition only. n/a
CLRVersion string Minimum version of the common language runtime (CLR) required. Valid for Desktop edition only. n/a
ProcessorArchitecture string None, X86 or Amd64 n/a
RequiredModules array Modules that must be imported into the global environment prior to importing this module n/a
RequiredAssemblies array Assemblies that must be loaded prior to importing this module n/a
ScriptsToProcess array Script files (.ps1) to be loaded when importing this module. Useful, for example, to export classes. n/a
TypesToProcess array Type Files (.ps1xml1) to be loaded when importing this module n/a
FormatsToProcess array Format Files (.ps1xml1) to be loaded when importing this module n/a
NestedModules array Modules to import as nested modules of the module specified in RootModule/ModuleToProcess n/a
FunctionsToExport array Functions to export from this module. For performance reasons, this entry should exist and not contain wildcards. @()
CmdletsToExport array Cmdlets to export from this module. For performance reasons, this entry should exist and not contain wildcards. @()
VariablesToExport string Variables to export '*'
AliasesToExport array Aliases to export from this module. For performance reasons, this entry should exist and not contain wildcards. @()
DscResourcesToExport array DSC resources to export from this module n/a
ModuleList array List of all modules that are packaged with this module n/a
FileList array List of all files that are package with this module n/a
PrivateData hash table Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. see below
HelpInfoURI string URI of HelpInfo n/a
DefaultCommandPrefix string Default prefix for commands exported from this module. Override the default prefix using import-Module -prefix. n/a

PrivateData

@{
  …
  PrivateData = @{
    PSData = @{
        # Tags = @()         # Tags applied to this module. These help with module discovery in online galleries.
        # LicenseUri   = ''  # An URL to the license for this module.
        # ProjectUri   = ''  # An URL to the main website for this project.
        # IconUri      = ''  # An URL to an icon representing this module.
        # ReleaseNotes = ''  # Release Notes of this module
    }
  }
  …
}

Minimalistic manifest

A minimalisitic manifest file for a module named TQ84 might look like so:
@{
   RootModule         = 'TQ84.psm1'
   ModuleVersion      = '0.0.1'

   RequiredAssemblies = @(
     'System.IO.Compression',
     'System.IO.Compression.ZipArchive'
   )

   RequiredModules    = @(
     'another-module'
   )

 #
 # List of the functions that are exported by the module.
 # Alternatively, functions can be exported more explicitly
 # with
 #    export-moduleMember -function get-foo
 # right after the definition of a function in the .psm1 file.
 #
   FunctionsToExport  = @(
     'get-foo'    ,
     'invoke-bar' ,
     'set-baz'
   )

 #
 # Aliases, that were defined in the module (.psm1) file with new-alias can be made «visible
 # to the world» with AliasesToExport:
 #
   AliasesToExport    = @(
     'intitialize-xyz'
   )

 #
 # Specify a formatting file to be imported
 # into the current session when the module is loaded:
 #
   FormatsToProcess   = @(
     'xyz.format.ps1xml'
   )

}

Exporting classes

Interestingly, a module manifest does not have an explicit way to export classes (with a key named for example ClassesToExport).
However, classes can be defined in a script file which is located in the same directory as the manifest file which then can be referenced from the manifest file with the ScriptsToProcess directive.
Apparently, the canonical way to use classes that are defined in a module is the using statement.

Index