Cmdlets

Choose a cmdlet from the list on the left or search for a specific cmdlet. Choose a cmdlet from the list or search for a specific cmdlet.
About Help  Providers
 

Remove-Module

Remove-Module

system.management.automation.dll

Synopsis

Removes modules from the current session.

Syntax

Remove-Module [-ModuleInfo] [-Force] [-FullyQualifiedName] [-Confirm] [-WhatIf] [<CommonParameters>]

Remove-Module [-Name] [-Force] [-Confirm] [-WhatIf] [<CommonParameters>]

Remove-Module [-FullyQualifiedName] [-Confirm] [-WhatIf] [<CommonParameters>]

Detailed Description

The Remove-Module cmdlet removes the members of a module, such as cmdlets and functions, from the current session.

If the module includes an assembly (.dll), all members that are implemented by the assembly are removed, but the assembly is not unloaded.

This cmdlet does not uninstall the module or delete it from the computer. It affects only the current Windows PowerShell session.

Parameters

-Force <SwitchParameter>

Removes read-only modules. By default, Remove-Module removes only read-write modules.

The ReadOnly and ReadWrite values are stored in AccessMode property of a module.

Aliases

None

Required?

false

Position

named

Default value

False

Accept pipeline input?

false

Accept wildcard characters?

false

-FullyQualifiedName <String[]>

Removes modules with names that are specified in the form of ModuleSpecification objects (described by the Remarks section of Module Specification Constructor (Hashtable) on MSDN). For example, the FullyQualifiedName parameter accepts a module name that is specified in the format @{ModuleName = "modulename"; ModuleVersion = "version_number"} or @{ModuleName = "modulename"; ModuleVersion = "version_number"; Guid = "GUID"}. ModuleName and ModuleVersion are required, but Guid is optional.

You cannot specify the FullyQualifiedName parameter in the same command as a Name parameter; the two parameters are mutually exclusive.

Aliases

none

Required?

false

Position

named

Default value

none

Accept pipeline input?

false

Accept wildcard characters?

false

-ModuleInfo <PSModuleInfo[]>

Specifies the module objects to remove. Enter a variable that contains a module object (PSModuleInfo) or a command that gets a module object, such as a Get-Module command. You can also pipe module objects to Remove-Module.

Aliases

None

Required?

true

Position

1

Default value

None

Accept pipeline input?

true (ByValue)

Accept wildcard characters?

false

-Name <String[]>

Specifies the names of modules to remove. Wildcard characters are permitted. You can also pipe name strings to Remove-Module.

Aliases

None

Required?

true

Position

1

Default value

None

Accept pipeline input?

true (ByValue)

Accept wildcard characters?

true

-Confirm <SwitchParameter>

Prompts you for confirmation before running the cmdlet.

Aliases

None

Required?

false

Position

named

Default value

false

Accept pipeline input?

false

Accept wildcard characters?

false

-WhatIf <SwitchParameter>

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Aliases

None

Required?

false

Position

named

Default value

false

Accept pipeline input?

false

Accept wildcard characters?

false

Input Type

System.String, System.Management.Automation.PSModuleInfo

Return Type

None

Notes

None

Examples

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

This command removes the BitsTransfer module from the current session.

PS C:\>Remove-Module -Name BitsTransfer

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

This command removes all modules from the current session.

PS C:\>Get-Module | Remove-Module

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

This command removes the BitsTransfer and PSDiagnostics modules from the current session.

The command uses a pipeline operator (|) to send the module names to Remove-Module. It uses the Verbose common parameter to get detailed information about the members that are removed.

The Verbose messages show the items that are removed. The messages differ because the BitsTransfer module includes an assembly that implements its cmdlets and a nested module with its own assembly. The PSDiagnostics module includes a module script file (.psm1) that exports functions.

PS C:\>"FileTransfer", "PSDiagnostics" | Remove-Module -Verbose
VERBOSE: Performing operation "Remove-Module" on Target "filetransfer (Path: 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\filetransfer\filetransfer.psd1')". 
VERBOSE: Performing operation "Remove-Module" on Target "Microsoft.BackgroundIntelligentTransfer.Management (Path: 'C:\Windows\assembly\GAC_MSIL\Microsoft.BackgroundIntelligentTransfer.Management\1.0.0.0__31bf3856ad364e35\Microsoft.BackgroundIntelligentTransfe
r.Management.dll')".
VERBOSE: Performing operation "Remove-Module" on Target "psdiagnostics (Path: 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\psdiagnostics\psdiagnostics.psd1')". 
VERBOSE: Removing imported function 'Start-Trace'. 
VERBOSE: Removing imported function 'Stop-Trace'. 
VERBOSE: Removing imported function 'Enable-WSManTrace'. 
VERBOSE: Removing imported function 'Disable-WSManTrace'. 
VERBOSE: Removing imported function 'Enable-PSWSManCombinedTrace'. 
VERBOSE: Removing imported function 'Disable-PSWSManCombinedTrace'. 
VERBOSE: Removing imported function 'Set-LogProperties'. 
VERBOSE: Removing imported function 'Get-LogProperties'. 
VERBOSE: Removing imported function 'Enable-PSTrace'. 
VERBOSE: Removing imported function 'Disable-PSTrace'. 
VERBOSE: Performing operation "Remove-Module" on Target "PSDiagnostics (Path: 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\psdiagnostics\PSDiagnostics.psm1')".

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

This command uses the ModuleInfo parameter to remove the BitsTransfer module.

PS C:\>$a = Get-Module BitsTransfer
PS C:\>Remove-Module -ModuleInfo $a

Online Version
Get-Module
Import-Module
about_Modules
about_modules