PowerShell for Windows Admins

Nov 30 2013   8:52AM GMT

CDXML: Module Manifest

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Last time we created a module using CDXML to wrap the Win32_Bios WMI class. This gave us a cmdlet – Get-Bios. As the intention is to create a number of modules that expose the WMI classes related to hardware we need a module manifest file (.psd1) to load them so that we can take advantage of module auto-loading in PowerShell 3 & 4

Remember – one WMI class per CDXML file and each CDXML file is treated as a module

I find the easiest way to create new manifest is run New-ModuleManifest and give it the full path to the psd1 file you want to create

New-ModuleManifest -Path C:\scripts\Modules\Hardware\Hardware.psd1 –PassThru

You can then open the file in ISE and edit to give this:

# Module manifest for module ‘Hardware’
# Generated by: richard
# Generated on: 30/11/2013


# Script module or binary module file associated with this manifest.
# RootModule = ”

# Version number of this module.
ModuleVersion = ’1.0′

# ID used to uniquely identify this module
GUID = ’55512ad7-c2aa-4678-818f-8f19b4f110dd’

# Author of this module
Author = ‘Richard’

# Company or vendor of this module
CompanyName = ‘Macdui’

# Copyright statement for this module
Copyright = ‘(c) 2013 Richard. All rights reserved.’

# Description of the functionality provided by this module
# Description = ”

# 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 Microsoft .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) 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 RootModule/ModuleToProcess
NestedModules = @(‘Win32_BIOS.cdxml’)

# Functions to export from this module
FunctionsToExport = @(‘Get-Bios’)

# 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 = @()

# Private data to pass to the module specified in RootModule/ModuleToProcess
# PrivateData = ”

# HelpInfo URI of this module
# HelpInfoURI = ”

# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ”


You can cut out the items you don’t need but I prefer to leave them as reminders of the commands.

Once the file is modified – save it back as Hardware.psd1

Start a new PowerShell console and your new module is available for use immediately.

This also means that you can add new CDXML files and test them independently of the module. Once you’re happy with the new functionality you add the appropriate lines to the module manifest.

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: