Modules in PowerShell
Modules are used to organize and distribute PowerShell code. They can contain functions, cmdlets, and other resources. Here's an example of a simple module:
# MyModule.psd1
@{
ModuleName = 'MyModule'
Version = '1.0.0'
RootModule = 'MyModule.psm1'
}
# MyModule.psm1
function Get-MyMessage {
return "Hello from MyModule!"
}
In this example, we define a module called MyModule that contains a single function called Get-MyMessage. The module is defined in a manifest file (MyModule.psd1) and the code is in a script module file (MyModule.psm1).
No comments:
Post a Comment