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

Syntax

  Copy Code
Get-Module [[-Name] <string[]>] [-All] [<CommonParameters>]

Get-Module [[-Name] <string[]>] [-All] [-ListAvailable] [<CommonParameters>]

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 selects 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 specified 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 <string[]>

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

Required?

false

Position?

1

Default Value

All imported or available modules.

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

true

<CommonParameters>

This command supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, OutBuffer, OutVariable, WarningAction, and WarningVariable. For more information, see about_CommonParameters.

Inputs and Outputs

The input type is the type of the objects that you can pipe to the cmdlet. The return type is the type of the objects that the cmdlet returns.

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 implement cmdlets or providers.

Example 1

  Copy Code
C:\PS>get-module

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






Example 2

  Copy Code
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 more information about PSModulePath, see about_Modules and about_Environment_Variables.






Example 3

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

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






Example 4

  Copy Code
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 module 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=143624.






Example 5

  Copy Code
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 module files that each script is exporting.






Example 6

  Copy Code
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="© 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

  Copy Code
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 property are not yet populated. These properties are populated only after the elements have been exported and the nested modules have been instantiated.






Example 8

  Copy Code
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.






See Also