How it works...
Script Modules are almost like scripts. When loading a PowerShell script, you would call the script with the . calling operator, and then use the functions within. In the case of a module, though, you use the Import-Module cmdlet. A module could be a collection of functions that have been saved as a psm1 file. As already mentioned, a module can be a simple one like the module we discussed in this recipe, or one that is much more complex and has many, many components.
In this recipe, the module exports only one member, which is the New-File cmdlet; the New-FileName function is not exposed for use. This is done using the Export-ModuleMember cmdlet. Had the cmdlet not been used, both functions would have been exported. The
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access