Skip to content

Commit aebe66d

Browse files
authored
Add Note about module assembly initializer and cleanup
1 parent f747598 commit aebe66d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

reference/docs-conceptual/developer/module/how-to-write-a-powershell-binary-module.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ The following procedure describes how to create and install a PowerShell binary
9292
your module into active memory. If you are using PowerShell 3.0 and later, simply calling the
9393
name of your module in code will also import it; for more information, see [Importing a PowerShell Module](./importing-a-powershell-module.md).
9494

95+
## Module Initialization and Cleanup Code
96+
97+
If your module needs to do something upon import or removal such as a discovery task or initialization, you can implement the `IModuleAssemblyInitializer` and `IModuleAssemblyCleanup` interfaces. Please note this is discouraged unless absolutely necessary, as to keep PowerShell performant you should lazily load things at the point your cmdlet(s) are called rather than on import.
98+
9599
## Importing Snap-in Assemblies as Modules
96100

97101
Cmdlets and providers that exist in snap-in assemblies can be loaded as binary modules. When the

0 commit comments

Comments
 (0)