header image

Snapins to modules

Posted by: | June 19, 2011 | No Comment |

In PowerShell v1 we had snapins to extend and add functionality. In PowerShell v2 modules were added. Modules give us more flexibility and control.

I’ve had to re-install a couple of snapins recently as part of the preparation for the presentation to the user group. I’d not put them on to my laptop when I rebuilt it as Windows 7.

The PowerShell provider for OneNote comes as an MSI that installs the snapin and registers it with Powershell – can’t do much with that – easier to leave as is.

The OpenXML snapin is available as source code or the binaries can be down loaded which consist of a dll and a help file.

To get the snapin loaded either use the supplied batch file to register the dll or create a module manifest file

#
# Module manifest for module ‘OpenXml’
#
# Generated by: Richard
#
# Generated on: 18/06/2011
#

@{

# Script module or binary module file associated with this manifest
ModuleToProcess = ‘OpenXml.PowerTools.dll’

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

# ID used to uniquely identify this module
GUID = ‘0275db55-3bf5-4eec-aecd-1a5cd1764c32’

# Author of this module
Author = ‘Richard’

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

# Copyright statement for this module
Copyright = ‘Macdui’

# Description of the functionality provided by this module
Description = ‘Loads OpenXML snapin’

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

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

}

 

Use new-ModuleManifest to create the file and save it with as a .psd1 file. 

Its now available as a module and can be used as such.

under: Modules, Office 2010, PowerShellV2