PowerShell 2.0: One Cmdlet at a Time 73 New-ModuleManifest
Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the New-ModuleManifest cmdlet.
What can I do with it?
PowerShell 2.0 introduces the concept of modules; essentially they are the evolution of snapins from PowerShell 1.0. Creators of Modules can use the New-ModuleManifest cmdlet to create a module manifest *.psd1 file which can be used to enhance to processes around a module, such as any prerequisites. Note: More info about writing a module manifest can be found here.
Example:
Create a new module manifest file using a mixture of default and specified values.
New-ModuleManifest
You will see that you are prompted to enter values to put in the manifest file and those which have defaults.
The *.psd1 file is created in the standard module location C:\Users\Username\Documents\WindowsPowerShell\Modules\ alongside the *.psm1 containing the module.
The contents of the *.psd1 file will look like the below:
Module manifest for module ‘Logfile-Module’
Generated by: Jonathan Medd
Generated on: 10/03/2010 # @{ # Script module or binary module file associated with this manifest ModuleToProcess = ‘Logile-Module.psm1’ # Version number of this module. ModuleVersion = ‘1.0’ # ID used to uniquely identify this module GUID = ‘876e3d17-66ac-40f6-9e10-09913679011a’ # Author of this module Author = ‘Jonathan Medd’ # Company or vendor of this module CompanyName = ‘Medd Enterprises’ # Copyright statement for this module Copyright = ‘Copyright © 2010 Jonathan Medd. All rights reserved.’ # Description of the functionality provided by this module Description = ‘Logfile Functions’ # Minimum version of the Windows PowerShell engine required by this module PowerShellVersion = ’’ # Name of the Windows PowerShell host required by this module PowerShellHostName = ’’ # Minimum version of the Windows PowerShell host required by this module PowerShellHostVersion = ’’ # Minimum version of the .NET Framework required by this module DotNetFrameworkVersion = ’’ # Minimum version of the common language runtime (CLR) required by this module CLRVersion = ’’ # Processor architecture (None, X86, Amd64, IA64) required by this module ProcessorArchitecture = ’’ # Modules that must be imported into the global environment prior to importing this module RequiredModules = @() # Assemblies that must be loaded prior to importing this module RequiredAssemblies = @() # Script files (.ps1) that are run in the caller’s environment prior to importing this module ScriptsToProcess = @() # Type files (.ps1xml) to be loaded when importing this module TypesToProcess = @() # Format files (.ps1xml) to be loaded when importing this module FormatsToProcess = @() # Modules to import as nested modules of the module specified in ModuleToProcess NestedModules = @() # Functions to export from this module FunctionsToExport = ‘*’ # Cmdlets to export from this module CmdletsToExport = ‘*’ # Variables to export from this module VariablesToExport = ‘*’ # Aliases to export from this module AliasesToExport = ‘*’ # List of all modules packaged with this module ModuleList = @() # List of all files packaged with this module FileList = ‘Logfile-Module.psd1’, ‘Logfile-Module.psm1’ # Private data to pass to the module specified in ModuleToProcess PrivateData = ’’ }
How could I have done this in PowerShell 1.0?
This functionality was not avaliable with snapins in PowerShell 1.0