powershellscripts.com

Tutorials  PowerShell Cmdlet Help for Get-Module



NAME
Get-Module

SYNOPSIS
Gets the modules that have been imported or that can be imported into the current session.

SYNTAX
Get-Module [-All] [-ListAvailable] [-Name ] []

Get-Module [[-Name] ] []


DESCRIPTION
The Get-Module cmdlet gets the modules that have been imported, or that can be imported, into the session.

Get-Module only gets modules; it does not import them. To import the modules into your session, use Import-Module.


PARAMETERS
-All []
Gets module objects for all module files.

Without the All parameter, Get-Module gets only the module object for the default module file. The cmdlet selec
ts file types in the following order: manifest (.psd1) files, script module (.psm1) files, and binary module (.
dll) files.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-ListAvailable []
Gets all of the modules that can be imported into the session. Get-Module gets the modules in the paths specifi
ed by the $env:PSModulePath environment variable.

Without this parameter, Get-Module gets only the modules that have been imported into the session.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Name
Gets only modules with the specified names or name patterns. Wildcards are permitted. You can also pipe the nam
es to Get-Module.

Required? false
Position? 1
Default value All imported or available modules.
Accept pipeline input? true (ByValue)
Accept wildcard characters? true


This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

INPUTS
System.String
You can pipe module names to Get-Module.


OUTPUTS
System.Management.Automation.PSModuleInfo
Get-Module returns objects that represent the modules.


NOTES


You can also refer to Get-Module by its alias, "gmo". For more information, see about_Aliases.

The All parameter returns module objects for all files with a .dll file name extension, even if they do not imp
lement cmdlets or providers.


-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-module


Description
-----------
This command gets the modules that have been imported into the current session.





-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-module -listAvailable


Description
-----------
This command gets the modules that can be imported into the current session.

Get-Module looks for available modules in the path specified by the $env:PSModulePath environment variable. For mor
e information about PSModulePath, see about_Modules and about_Environment_Variables.





-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-module -listAvailable -all


Description
-----------
This command gets all of the exported files for all available modules.





-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-module | get-member -type property

TypeName: System.Management.Automation.PSModuleInfo

Name MemberType Definition
---- ---------- ----------
AccessMode Property System.Management.Automation.ModuleAcc
Description Property System.String Description {get;set;}
ExportedAliases Property System.Collections.Generic.Dictionary`
ExportedCmdlets Property System.Collections.Generic.Dictionary`
ExportedFunctions Property System.Collections.Generic.Dictionary`
ExportedVariables Property System.Collections.Generic.Dictionary`
Guid Property System.Guid Guid {get;}
ModuleBase Property System.String ModuleBase {get;}
ModuleType Property System.Management.Automation.ModuleTyp
Name Property System.String Name {get;}
NestedModules Property System.Collections.ObjectModel.ReadOnl
OnRemove Property System.Management.Automation.ScriptBlo
Path Property System.String Path {get;}
PrivateData Property System.Object PrivateData {get;set;}
SessionState Property System.Management.Automation.SessionSt
Version Property System.Version Version {get;}


Description
-----------
This command get the properties of the PSModuleInfo object that Get-Module returns. There is one object for each mo
dule file.

You can use the properties to format and filter the module objects. For more information about the properties, see
"PSModule Properties" in the MSDN (Microsoft Developer Network) library at http://go.microsoft.com/fwlink/?LinkId=1
43624.





-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-module -listAvailable -all | format-table -property name, moduletype, path -groupby name -auto

Name: MyTestCmdlets

Name ModuleType Path
---- ---------- ----
MyTestCmdlets Script C:\Windows\system32\WindowsPowerShell\v1.0\Modules\TestCmdlets\TestCmdlets.dll


Name: PSDiagnostics

Name ModuleType Path
---- ---------- ----
PSDiagnostics Manifest C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDiagnostics\PSDiagnostics.psd1
PSDiagnostics Script C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDiagnostics\PSDiagnostics.psm1


Name: FileTransfer

Name ModuleType Path
---- ---------- ----
FileTransfer Manifest C:\Windows\system32\WindowsPowerShell\v1.0\Modules\FileTransfer\FileTransfer.psd1


Description
-----------
This command gets all module files (imported and available) and groups them by module name. This lets you see the m
odule files that each script is exporting.





-------------------------- EXAMPLE 6 --------------------------

C:\PS>$m = get-module -list -name FileTransfer | where {$_.moduletype -eq "Manifest"}

C:\PS> get-content $m.path

@{
GUID="{8FA5064B-8479-4c5c-86EA-0D311FE48875}"
Author="Microsoft Corporation"
CompanyName="Microsoft Corporation"
Copyright="c Microsoft Corporation. All rights reserved."
ModuleVersion="1.0.0.0"
Description="Windows Powershell File Transfer Module"
PowerShellVersion="2.0"
CLRVersion="2.0"
NestedModules="Microsoft.BackgroundIntelligentTransfer.Management"
FormatsToProcess="FileTransfer.Format.ps1xml"
RequiredAssemblies=Join-Path $psScriptRoot "Microsoft.BackgroundIntelligentTransfer.Management.Interop.dll"
}


Description
-----------
These commands display the contents of the module manifest for the Windows PowerShell File Transfer module.

The first command gets the PSModuleInfo object that represent the module manifest for the File Transfer module. It
saves the object in the $m variable.

The second command uses dot notation to get the path to the manifest file, which is stored in the Path property of
the object. Then, it uses the Get-Content cmdlet to get the content of the manifest file in the specified path.

Modules are not required to have manifest files. When they do have a manifest file, a manifest is required only to
include a version number. However, manifest files often provide useful information about a module, its requirements
, and its contents.





-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-module -listAvailable -name FileTransfer | format-list -property *

Name : FileTransfer
Path : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\FileTransfer\FileTransfer.psd1
Description : Powershell File Transfer Module
Guid : 8fa5064b-8479-4c5c-86ea-0d311fe48875
ModuleBase : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\FileTransfer
PrivateData :
Version : 1.0.0.0
ModuleType : Manifest
AccessMode : ReadWrite
ExportedFunctions : {}
ExportedCmdlets : {}
NestedModules : {}
ExportedVariables : {}
ExportedAliases : {}
SessionState : System.Management.Automation.SessionState
OnRemove :


Description
-----------
This command displays all of the properties of the FileTransfer module in a list.

Because the module has not yet been imported into the session, the Exported* properties and the NestedModules prope
rty are not yet populated. These properties are populated only after the elements have been exported and the nested
modules have been instantiated.





-------------------------- EXAMPLE 8 --------------------------

C:\PS>dir (get-module -listavailable FileTransfer).modulebase

Directory: C:\Windows\system32\WindowsPowerShell\v1.0\Modules\FileTransfer


Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 12/16/2008 12:36 PM en-US
-a--- 11/19/2008 11:30 PM 16184 FileTransfer.Format.ps1xml
-a--- 11/20/2008 11:30 PM 1044 FileTransfer.psd1
-a--- 12/16/2008 12:20 AM 108544 Microsoft.BackgroundIntelligentTransfer.Management.Interop.dll


Description
-----------
This command lists the files in the module's directory. This is another way to determine what is in a module before
you import it. Some modules might have help files or ReadMe files that describe the module.






RELATED LINKS
Online version: http://go.microsoft.com/fwlink/?LinkID=141552
Import-Module
New-Module
Remove-Module
about_Modules