CmdID

CmdID / PowerShell / Cmdlets / Remove

Remove-Module

Removes modules from the current session. PowerShell reference

From the PowerShell reference 6 parameters Alias rmo

Opens CmdID with your command, read as PowerShell. It is read in your browser and sent nowhere.

What it does

from the PowerShell reference, CC BY 4.0

Removes modules from the current session. 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 isn't unloaded. This cmdlet doesn't uninstall the module or delete it from the computer. It affects only the current PowerShell session.

Remove-Module [-Name] <String[]> [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]
Remove-Module [-FullyQualifiedName] <ModuleSpecification[]> [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]
Remove-Module [-ModuleInfo] <PSModuleInfo[]> [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]

Remove a module

Remove-Module -Name "BitsTransfer"Identify

Remove all modules

Get-Module | Remove-ModuleIdentify

Remove modules by using the pipeline

"FileTransfer", "PSDiagnostics" | Remove-Module -VerboseIdentify

Remove a module using ModuleInfo

$a = Get-Module BitsTransfer Remove-Module -ModuleInfo $aIdentify

Using the OnRemove event

$OnRemoveScript = { # perform cleanup $cachedSessions | Remove-PSSession } $ExecutionContext.SessionState.Module.OnRemove += $OnRemoveScript $registerEngineEventSplat = @{ SourceIdentifier = ([System.Management.Automation.PSEngineEvent]::Exiting) Action = $OnRemoveScript } Register-EngineEvent @registerEngineEventSplatIdentify

Its page in the reference: Remove-Module.

Parameters

6 in the PowerShell reference
-ForceIndicates that this cmdlet 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.
-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.
-ModuleInfoSpecifies the module objects to remove. Enter a variable that contains a PSModuleInfo object or a command that gets a module object, such as a Get-Module command. You can also pipe module objects to Remove-Module.
-NameSpecifies the names of modules to remove. Wildcard characters are permitted. You can also pipe name strings to Remove-Module.
-ConfirmPrompts you for confirmation before running the cmdlet.
-WhatIfShows what would happen if the cmdlet runs. The cmdlet isn't run.