Remove-Module
Published: February 29, 2012
Updated: August 15, 2012
Applies To: Windows PowerShell 2.0, Windows PowerShell 3.0
Remove-Module
Aliases
The following abbreviations are aliases for this cmdlet:
- rmo
Syntax
Parameter Set: ModuleInfo Remove-Module [-ModuleInfo] <PSModuleInfo[]> [-Force] [-Confirm] [-WhatIf] [ <CommonParameters>] Parameter Set: name Remove-Module [-Name] <String[]> [-Force] [-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
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 |
-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. Wildcards 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
Prompts you for confirmation before running the cmdlet.
|
Required? |
false |
|
Position? |
named |
|
Default Value |
false |
|
Accept Pipeline Input? |
false |
|
Accept Wildcard Characters? |
false |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
|
Required? |
false |
|
Position? |
named |
|
Default Value |
false |
|
Accept Pipeline Input? |
false |
|
Accept Wildcard Characters? |
false |
<CommonParameters>
This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/p/?LinkID=113216).
Inputs
The input type is the type of the objects that you can pipe to the cmdlet.
-
System.String, System.Management.Automation.PSModuleInfo
You can pipe module names (strings) and module objects to Remove-Module.
Outputs
The output type is the type of the objects that the cmdlet emits.
-
None
Remove-Module does not generate any output.
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 -VerboseVERBOSE: 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.BackgroundIntelligentTransfer.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 BitsTransferPS C:\>Remove-Module -ModuleInfo $a
Related topics