CmdID / PowerShell / Cmdlets / Get
Get-Module
List the modules imported in the current session or that can be imported from the PSModulePath. PowerShell reference
From the PowerShell reference
10 parameters
Alias gmo
1 Sigma rule looks for it
What it does
List the modules imported in the current session or that can be imported from the PSModulePath. The Get-Module cmdlet lists the PowerShell modules that have been imported, or that can be imported, into a PowerShell session. Without parameters, Get-Module gets modules that have been imported into the current session. The ListAvailable parameter is used to list the modules that are available to be imported from the paths specified in the PSModulePath environment variable ($Env:PSModulePath). The module object that Get-Module returns contains valuable information about the module. You can also pipe the module objects to other cmdlets, such as the Import-Module and Remove-Module cmdlets. Get-Module lists modules, but it does not import them. Starting in Windows PowerShell 3.0, modules are automatically imported when you use a command in the module, but a Get-Module command does not trigger an automatic import. You can also import the modules into your session using the Import-Module cmdlet. Starting in Windows PowerShell 3.0, you can get and then, import modules from remote sessions into the local session. This strategy uses the Implicit Remoting feature of PowerShell and is equivalent to using the Import-PSSession cmdlet. When you use commands in modules imported from another session, the commands run implicitly in the remote session. This feature lets you manage the remote computer from the local session. Also, starting in Windows PowerShell 3.0, you can use Get-Module and Import-Module to get and import Common Information Model (CIM) modules. CIM modules define cmdlets in Cmdlet Definition XML (CDXML) files. This feature lets you use cmdlets that are implemented in non-managed code assemblies, such as those written in C++. Implicit remoting can be used to manage remote computers that have PowerShell remoting enabled. Create a PSSession on the remote computer and then use the PSSession parameter of Get-Module to get the PowerShell modules in the remote session. When you import a module from the remote session the imported commands run in the session on the remote computer. You can use a similar strategy to manage computers that do not have PowerShell remoting enabled. These include computers that are not running the Windows operating system, and computers that have PowerShell but do not have PowerShell remoting enabled. …
Get-Module [[-Name] <String[]>] [-FullyQualifiedName <ModuleSpecification[]>] [-All] [<CommonParameters>]Get-Module [[-Name] <String[]>] [-FullyQualifiedName <ModuleSpecification[]>] [-All] [-ListAvailable] [-PSEdition <String>] [-Refresh] [<CommonParameters>]Get-Module [[-Name] <String[]>] [-FullyQualifiedName <ModuleSpecification[]>] [-ListAvailable] [-PSEdition <String>] [-Refresh] -PSSession <PSSession> [<CommonParameters>]Get-Module [[-Name] <String[]>] [-FullyQualifiedName <ModuleSpecification[]>] [-ListAvailable] [-Refresh] -CimSession <CimSession> [-CimResourceUri <Uri>] [-CimNamespace <String>] [<CommonParameters>]
Get modules imported into the current session
Get-ModuleIdentifyGet installed modules and available modules
Get-Module -ListAvailableIdentifyGet all exported files
Get-Module -ListAvailable -AllIdentifyGet a module by its fully qualified name
$FullyQualifiedName = @{ModuleName="Microsoft.PowerShell.Management";ModuleVersion="3.1.0.0"}
Get-Module -FullyQualifiedName $FullyQualifiedName | Format-Table -Property Name,VersionIdentifyGet properties of a module
Get-Module | Get-Member -MemberType Property | Format-Table NameIdentifyGroup all modules by name
Get-Module -ListAvailable -All | Format-Table -Property Name, ModuleType, Path -GroupBy NameIdentifyDisplay the contents of a module manifest
# First command
$m = Get-Module -List -Name BitsTransfer
# Second command
Get-Content $m.PathIdentifyList files in module directory
dir (Get-Module -ListAvailable FileTransfer).ModuleBaseIdentifyGet modules installed on a computer
$s = New-PSSession -ComputerName Server01
Get-Module -PSSession $s -ListAvailableIdentifyManage a computer that does not run the Windows operating system
$cs = New-CimSession -ComputerName RSDGF03
Get-Module -CimSession $cs -Name Storage | Import-Module
Get-Command Get-DiskIdentifyIts page in the reference: Get-Module.
Parameters
-AllIndicates that this cmdlet gets all modules in each module folder, including nested modules, manifest (.psd1) files, script module (.psm1) files, and binary module (.dll) files. Without this parameter, Get-Module gets only the default module in each module folder.-CimNamespaceSpecifies the namespace of an alternate CIM provider that exposes CIM modules. The default value is the namespace of the Module Discovery WMI provider.
Use this parameter to get CIM modules from computers and devices that are not running the Windows operating system.
This parameter was introduced in Windows PowerShell 3.0.-CimResourceUriSpecifies an alternate location for CIM modules. The default value is the resource URI of the Module Discovery WMI provider on the remote computer.
Use this parameter to get CIM modules from computers and devices that are not running the Windows operating system.
This parameter was introduced in Windows PowerShell 3.0.-CimSessionSpecifies a CIM session on the remote computer. Enter a variable that contains the CIM session or a
command that gets the CIM session, such as a
Get-CimSession command.
Get-Module uses the CIM session connection to get modules from the remote computer. When you import the module by using the Import-Module cmdlet and use the commands from the imported module in the current session, the commands actually run on the remote computer.
You can use this parameter to get modules from computers and devices that are not running the Windows operating system, and computers that have PowerShell, but do not have PowerShell remoting enabled.
The CimSession parameter gets all modules in the CIMSession. However, you can import only
CIM-based and Cmdlet Definition XML (CDXML)-based modules.-FullyQualifiedNameThe value can be a module name, a full module specification, or a path to a module file.
When the value is a path, the path can be fully qualified or relative. A relative path is resolved relative to the script that contains the using statement.
When the value is a name or module specification, PowerShell searches the PSModulePath for the specified module.
A module specification is a hashtable that has the following keys.
- ModuleName - Required Specifies the module name.
- GUID - Optional Specifies the GUID of the module.
- It's also Required to specify at least one of the three below keys.
- ModuleVersion - Specifies a minimum acceptable version of the module.
- MaximumVersion - Specifies the maximum acceptable version of the module.
- RequiredVersion - Specifies an exact, required version of the module. This can't be used with
the other Version keys.
You cannot specify the FullyQualifiedName parameter in the same command as a Name parameter.-ListAvailableBy default, Get-Module only returns the modules that have been imported into the current session.
With this parameter the command lists modules installed in any path included in the
$env:PSModulePath environment variable.-NameSpecifies names or name patterns of modules that this cmdlet gets. Wildcard characters are permitted. You can also pipe the names to Get-Module. You cannot specify the FullyQualifiedName parameter in the same command as a Name parameter.
Name cannot accept a module GUID as a value. To return modules by specifying a GUID, use FullyQualifiedName instead.-PSEditionGets the modules that support specified edition of PowerShell.
The acceptable values for this parameter are:
- Desktop
- Core
The Get-Module cmdlet checks CompatiblePSEditions property of PSModuleInfo object for the specified value and returns only those modules that have it set.
NOTE:
- Desktop Edition: Built on .NET Framework and provides compatibility with scripts and modules
targeting versions of PowerShell running on full footprint editions of Windows such as Server
Core and Windows Desktop.
- Core Edition: Built on .NET Core and provides compatibility with scripts and modules
targeting versions of PowerShell running on reduced footprint editions of Windows such as Nano
Server and Windows IoT.-PSSessionGets the modules in the specified user-managed PowerShell session (PSSession). Enter a variable that contains the session, a command that gets the session, such as a Get-PSSession command, or a command that creates the session, such as a New-PSSession command.
When the session is connected to a remote computer, you must specify the ListAvailable parameter.
A Get-Module command that uses the PSSession parameter is equivalent to using the
Invoke-Command cmdlet to run a Get-Module -ListAvailable command in a PSSession.
This parameter was introduced in Windows PowerShell 3.0.-RefreshIndicates that this cmdlet refreshes the cache of installed commands. The command cache is created when the session starts. It enables the Get-Command cmdlet to get commands from modules that are not imported into the session.
This parameter is designed for development and testing scenarios in which the contents of modules have changed since the session started.
When you specify the Refresh parameter in a command, you must specify ListAvailable.
This parameter was introduced in Windows PowerShell 3.0.