You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Update module manifest how-to
Updated example template
* Update module manifest how-to
Update manifest elements table to better reflect current default manifest properties and usage.
Replaced reference to editing with ISE with VS Code.
* Update how-to-write-a-powershell-module-manifest.md
Copy file name to clipboardExpand all lines: developer/module/how-to-write-a-powershell-module-manifest.md
+52-25Lines changed: 52 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@ For simple modules that contain only a single .psm1 or binary assembly, a module
35
35
36
36
2. Add in any additional elements to the manifest that you want to have in the file.
37
37
38
-
Generally speaking, this will probably be done in whatever text editor you prefer, such as Notepad. However this technically is a script file that contains code, so you may wish to edit it in an actual scripting or development environment, such as the PowerShell ISE. Again, note that all elements of a manifest file are optional, except for the ModuleVersion number.
38
+
Generally speaking, this will probably be done in whatever text editor you prefer, such as Notepad. However this technically is a script file that contains code, so you may wish to edit it in an actual scripting or development environment, such as Visual Studio Code. Again, note that all elements of a manifest file are optional, except for the ModuleVersion number.
39
39
40
40
For descriptions of the keys and values you can have in a module manifest, see the **Module Manifest Elements** below. For additional information, see the parameter descriptions in the [New-ModuleManifest](/powershell/module/Microsoft.PowerShell.Core/New-ModuleManifest) cmdlet.
41
41
@@ -77,16 +77,16 @@ The following table describes the elements you can have in a module manifest
77
77
|RequiredModules<br /><br /> Type: [string[]]|@()|Modules that must be imported into the global environment prior to importing this module. This will load any modules listed unless they have already been loaded. (For example, some modules may already be loaded by a different module.). It is also possible to specify a specific version to load using `RequiredVersion` rather than `ModuleVersion`. When using `ModuleVersion` it will load the newest version available with a minimum of the version specified.<br /><br /> Example: `RequiredModules = @(@{ModuleName="myDependentModule"; ModuleVersion="2.0"; Guid="cfc45206-1e49-459d-a8ad-5b571ef94857"})`<br /><br /> Example: `RequiredModules = @(@{ModuleName="myDependentModule"; RequiredVersion="1.5"; Guid="cfc45206-1e49-459d-a8ad-5b571ef94857"})`|
78
78
|RequiredAssemblies<br /><br /> Type: [string[]]|@()|Assemblies that must be loaded prior to importing this module.<br /><br /> Note that unlike RequiredModules, PowerShell will load the RequiredAssemblies if they are not already loaded.|
79
79
|ScriptsToProcess<br /><br /> Type: [string[]]|@()|Script (.ps1) files that are run in the caller's session state when the module is imported. This could be the global session state or, for nested modules, the session state of another module. You can use these scripts to prepare an environment just as you might use a login script.<br /><br /> These scripts are run before any of the modules listed in the manifest are loaded.|
80
-
|TypesToProcess<br /><br /> Type: [Object[]]|@()|Type files (.ps1xml) to be loaded when importing this module.|
81
-
|FormatsToProcess<br /><br /> Type: [Object[]]|@()|Format files (.ps1xml) to be loaded when importing this module.|
82
-
|NestedModules<br /><br /> Type: [Object[]]|@()|Modules to import as nested modules of the module specified in RootModule/ModuleToProcess.<br /><br /> Adding a module name to this element is similar to calling `Import-Module` from within your script or assembly code. The main difference is that it's easier to see what you are loading here in the manifest file. Also, if a module fails to load here, you will not yet have loaded your actual module.<br /><br /> In addition to other modules, you may also load script (.ps1) files here. These files will execute in the context of the root module. (This is equivalent to dot sourcing the script in your root module.)|
83
-
|FunctionsToExport<br /><br /> Type: String|'*'|Specifies the functions that the module exports (wildcard characters are permitted) to the caller's session state. By default, all functions are exported. You can use this key to restrict the functions that are exported by the module.<br /><br /> The caller's session state can be the global session state or, for nested modules, the session state of another module. When chaining nested modules, all functions that are exported by a nested module will be exported to the global session state unless a module in the chain restricts the function by using the FunctionsToExport key.<br /><br /> If the manifest also exports aliases for the functions, this key can remove functions whose aliases are listed in the AliasesToExport key, but this key cannot add function aliases to the list.|
84
-
|CmdletsToExport<br /><br /> Type: String|'*'|Specifies the cmdlets that the module exports (wildcard characters are permitted). By default, all cmdlets are exported. You can use this key to restrict the cmdlets that are exported by the module.<br /><br /> The caller's session state can be the global session state or, for nested modules, the session state of another module. When you are chaining nested modules, all cmdlets that are exported by a nested module will be ultimately exported to the global session state unless a module in the chain restricts the cmdlet by using the CmdletsToExport key.<br /><br /> If the manifest also exports aliases for the cmdlets, this key can remove cmdlets whose aliases are listed in the AliasesToExport key, but this key cannot add cmdlet aliases to the list.|
85
-
|VariablesToExport<br /><br /> Type: String|'*'|Specifies the variables that the module exports (wildcard characters are permitted) to the caller's session state. By default, all variables are exported. You can use this key to restrict the variables that are exported by the module.<br /><br /> The caller's session state can be the global session state or, for nested modules, the session state of another module. When you are chaining nested modules, all variables that are exported by a nested module will be exported to the global session state unless a module in the chain restricts the variable by using the VariablesToExport key.<br /><br /> If the manifest also exports aliases for the variables, this key can remove variables whose aliases are listed in the AliasesToExport key, but this key cannot add variable aliases to the list.|
86
-
|AliasesToExport<br /><br /> Type: String|'*'|Specifies the aliases that the module exports (wildcard characters are permitted) to the caller's session state. By default, all aliases are exported. You can use this key to restrict the aliases that are exported by the module.<br /><br /> The caller's session state can be the global session state or, for nested modules, the session state of another module. When you are chaining nested modules, all aliases that are exported by a nested module will be ultimately exported to the global session state unless a module in the chain restricts the alias by using the AliasesToExport key.|
80
+
|TypesToProcess<br /><br /> Type: [string[]]|@()|Type files (.ps1xml) to be loaded when importing this module.|
81
+
|FormatsToProcess<br /><br /> Type: [string[]]|@()|Format files (.ps1xml) to be loaded when importing this module.|
82
+
|NestedModules<br /><br /> Type: [string[]]|@()|Modules to import as nested modules of the module specified in RootModule/ModuleToProcess.<br /><br /> Adding a module name to this element is similar to calling `Import-Module` from within your script or assembly code. The main difference is that it's easier to see what you are loading here in the manifest file. Also, if a module fails to load here, you will not yet have loaded your actual module.<br /><br /> In addition to other modules, you may also load script (.ps1) files here. These files will execute in the context of the root module. (This is equivalent to dot sourcing the script in your root module.)|
83
+
|FunctionsToExport<br /><br /> Type: [string[]]|@()|Specifies the functions that the module exports (wildcard characters are permitted but discouraged) to the caller's session state. By default, no functions are exported. You can use this key to list the functions that are exported by the module.<br /><br /> The caller's session state can be the global session state or, for nested modules, the session state of another module. When chaining nested modules, all functions that are exported by a nested module will be exported to the global session state unless a module in the chain restricts the function by using the FunctionsToExport key.<br /><br /> If the manifest also exports aliases for the functions, this key can remove functions whose aliases are listed in the AliasesToExport key, but this key cannot add function aliases to the list.|
84
+
|CmdletsToExport<br /><br /> Type: [string[]]|@()|Specifies the cmdlets that the module exports (wildcard characters are permitted but discouraged). By default, no cmdlets are exported. You can use this key to list the cmdlets that are exported by the module.<br /><br /> The caller's session state can be the global session state or, for nested modules, the session state of another module. When you are chaining nested modules, all cmdlets that are exported by a nested module will be ultimately exported to the global session state unless a module in the chain restricts the cmdlet by using the CmdletsToExport key.<br /><br /> If the manifest also exports aliases for the cmdlets, this key can remove cmdlets whose aliases are listed in the AliasesToExport key, but this key cannot add cmdlet aliases to the list.|
85
+
|VariablesToExport<br /><br /> Type: string|'*'|Specifies the variables that the module exports (wildcard characters are permitted) to the caller's session state. By default, all variables are exported. You can use this key to restrict the variables that are exported by the module.<br /><br /> The caller's session state can be the global session state or, for nested modules, the session state of another module. When you are chaining nested modules, all variables that are exported by a nested module will be exported to the global session state unless a module in the chain restricts the variable by using the VariablesToExport key.<br /><br /> If the manifest also exports aliases for the variables, this key can remove variables whose aliases are listed in the AliasesToExport key, but this key cannot add variable aliases to the list.|
86
+
|AliasesToExport<br /><br /> Type: [string[]]|@()|Specifies the aliases that the module exports (wildcard characters are permitted but discouraged) to the caller's session state. By default, no aliases are exported. You can use this key to list the aliases that are exported by the module.<br /><br /> The caller's session state can be the global session state or, for nested modules, the session state of another module. When you are chaining nested modules, all aliases that are exported by a nested module will be ultimately exported to the global session state unless a module in the chain restricts the alias by using the AliasesToExport key.|
87
87
|ModuleList<br /><br /> Type: [string[]]|@()|Specifies all the modules that are packaged with this module. These modules can be entered by name (a comma-separated string) or as a hash table with ModuleName and GUID keys. The hash table can also have an optional ModuleVersion key. The ModuleList key is designed to act as a module inventory. These modules are not automatically processed.|
88
88
|FileList<br /><br /> Type: [string[]]|@()|List of all files packaged with this module. As with ModuleList, FileList is to assist you as an inventory list, and is not otherwise processed.|
89
-
|PrivateData<br /><br /> Type: [object]|' '|Specifies any private data that needs to be passed to the root module specified by the RootModule/ModuleToProcess key.|
89
+
|PrivateData<br /><br /> Type: [object]|@{...}|Specifies any private data that needs to be passed to the root module specified by the RootModule/ModuleToProcess key.|
90
90
|HelpInfoURI<br /><br /> Type: string|' '|HelpInfo URI of this module.|
91
91
|DefaultCommandPrefix<br /><br /> Type: string|' '|Default prefix for commands exported from this module. Override the default prefix using `Import-Module` -Prefix.|
92
92
@@ -100,19 +100,22 @@ The following sample module manifest shows the keys and default values in a modu
100
100
#
101
101
# Generated by: User01
102
102
#
103
-
# Generated on: 1/24/2012
103
+
# Generated on: 2019-10-09
104
104
#
105
105
106
106
@{
107
107
108
-
# Script module or binary module file associated with this manifest
109
-
#RootModule = ''
108
+
# Script module or binary module file associated with this manifest.
109
+
#RootModule = ''
110
110
111
111
# Version number of this module.
112
112
ModuleVersion = '1.0'
113
113
114
+
# Supported PSEditions
115
+
# CompatiblePSEditions = @()
116
+
114
117
# ID used to uniquely identify this module
115
-
GUID = 'd0a9150d-b6a4-4b17-a325-e3a24fed0aa9'
118
+
GUID = 'b888e5a2-8578-4c0b-938d-0cd9b5b836ba'
116
119
117
120
# Author of this module
118
121
Author = 'User01'
@@ -121,7 +124,7 @@ Author = 'User01'
121
124
CompanyName = 'Unknown'
122
125
123
126
# Copyright statement for this module
124
-
Copyright = '(c) 2012 User01. All rights reserved.'
127
+
Copyright = '(c) 2019 User01. All rights reserved.'
125
128
126
129
# Description of the functionality provided by this module
127
130
# Description = ''
@@ -135,10 +138,10 @@ Copyright = '(c) 2012 User01. All rights reserved.'
135
138
# Minimum version of the Windows PowerShell host required by this module
136
139
# PowerShellHostVersion = ''
137
140
138
-
# Minimum version of the .NET Framework required by this module
141
+
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
139
142
# DotNetFrameworkVersion = ''
140
143
141
-
# Minimum version of the common language runtime (CLR) required by this module
144
+
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
142
145
# CLRVersion = ''
143
146
144
147
# Processor architecture (None, X86, Amd64) required by this module
@@ -150,7 +153,7 @@ Copyright = '(c) 2012 User01. All rights reserved.'
150
153
# Assemblies that must be loaded prior to importing this module
151
154
# RequiredAssemblies = @()
152
155
153
-
# Script files (.ps1) that are run in the caller's environment prior to importing this module
156
+
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
154
157
# ScriptsToProcess = @()
155
158
156
159
# Type files (.ps1xml) to be loaded when importing this module
@@ -162,26 +165,50 @@ Copyright = '(c) 2012 User01. All rights reserved.'
162
165
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
163
166
# NestedModules = @()
164
167
165
-
# Functions to export from this module
166
-
FunctionsToExport = '*'
168
+
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
169
+
FunctionsToExport = @()
167
170
168
-
# Cmdlets to export from this module
169
-
CmdletsToExport = '*'
171
+
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
172
+
CmdletsToExport = @()
170
173
171
174
# Variables to export from this module
172
175
VariablesToExport = '*'
173
176
174
-
# Aliases to export from this module
175
-
AliasesToExport = '*'
177
+
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
178
+
AliasesToExport = @()
179
+
180
+
# DSC resources to export from this module
181
+
# DscResourcesToExport = @()
176
182
177
183
# List of all modules packaged with this module
178
184
# ModuleList = @()
179
185
180
186
# List of all files packaged with this module
181
187
# FileList = @()
182
188
183
-
# Private data to pass to the module specified in RootModule/ModuleToProcess
184
-
# PrivateData = ''
189
+
# 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.
190
+
PrivateData = @{
191
+
192
+
PSData = @{
193
+
194
+
# Tags applied to this module. These help with module discovery in online galleries.
0 commit comments