Contact Info

Crumbtrail

ActiveXperts.com » Administration » Powershell » Powershell 2.0 » New-Module

New-Module - Powershell 2.0 CmdLet

Microsoft Windows PowerShell is a command-line shell and scripting tool based on the Microsoft .NET Framework. It is designed for system administrators, engineers and developers to control and automate the administration of Windows and applications.

More than hundred command-line tools (so called "cmdlets") can be used to perform system administration tasks and Windows Management Instrumentation (WMI). These cmdlets are easy to use, with standard naming conventions and common parameters, and standard tools for piping, sorting, filtering, and formatting data and objects.

New-Module


Short description
Creates a new dynamic module that exists only in memory.

Syntax
New-Module [-Name] <string> [-ScriptBlock] <scriptblock> [-ArgumentList <Object[]>] [-AsCustomObject] [-Cmdlet <str
ing[]>] [-Function <string[]>] [-ReturnResult] [<CommonParameters>]

New-Module [-ScriptBlock] <scriptblock> [-ArgumentList <Object[]>] [-AsCustomObject] [-Cmdlet <string[]>] [-Functio
n <string[]>] [-ReturnResult] [<CommonParameters>]

Description
The New-Module cmdlet creates a dynamic module from a script block. The members of the dynamic module, such as func
tions and variables, are immediately available in the session and remain available until you close the session.

Like static modules, by default, the cmdlets and functions in a dynamic module are exported and the variables and a
liases are not. However, you can use the Export-ModuleMember cmdlet and the parameters of New-Module to override th
e defaults.

Dynamic modules  exist only in memory, not on disk. Like all modules, the members of dynamic modules run in a priva
te module scope that is a child of the global scope. Get-Module cannot get a dynamic module, but Get-Command can ge
t the exported members.

To make a dynamic module available to Get-Module, pipe a New-Module command to Import-Module, or pipe the module ob
ject that New-Module returns to Import-Module. This action adds the dynamic module to the Get-Module list, but it d
oes not save the module to disk or make it persistent.