Creating a module
A module most often consists of one or more functions. Typically, you create modules in one or more files starting with a psm1
file. The psm1
file is known as the root module.
The root module
The root module has a psm1
extension and is otherwise like any other script file in PowerShell. The root module file is named after the module.
The psm1
file can contain all the module content directly; nothing else is required to create a module.
A module requires content. Chapter 19, Classes and Enumerations, ended by creating a class-based DSC resource to manage the computer description property. You'll rebuild this content of the resource and use it as the basis for creating a module during this chapter.
Here is the first command to add to a file named LocalMachine.psm1
:
function Get-ComputerDescription {
[CmdletBinding()]
[OutputType([string])]
param ( )
$getParams = @{
Path = 'HKLM:\SYSTEM\CurrentControlSet...