Remove-PSSnapin

 

SYNOPSIS

Removes Windows PowerShell snap-ins from the current console.

 

SYNTAX

Remove-PSSnapin [-name] <string[]> [-passThru] [-whatIf] [-confirm] [<CommonParameters>]

 

DETAILED DESCRIPTION

The Remove-PSSnapIn cmdlet removes a Windows PowerShell snap-in from the current console. You can use it to remove snap-ins that you have added to Windows PowerShell, but you cannot use it to remove the snap-ins that are installed with Windows PowerShell. After a snap-in is removed, it is still loaded, but the cmdlets and providers that the snap-in supports are no longer available in the console. The changes affect only the current console, unless you use Export-Consoleto save the console.

 

PARAMETERS

 

-name <string[]>

The unique-name(s) of the PSSnapIn(s) to remove from the current console file. The parameter name ("-Name") is optional.

 

Required?

true

Position?

1

Default value

 

Accept pipeline input?  

true (ByPropertyName)

Accept wildcard characters? 

false

 

-passThru <SwitchParameter>

Passes the object created by this cmdlet through the pipeline. By default, this cmdlet does not pass any objects through the pipeline.

 

Required?

false

Position?

named

Default value

False

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-whatIf

Describes what would happen if you executed the command without actually executing the command.

 

Required?

false

Position?

named

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-confirm

Prompts you for confirmation before executing the command.

 

Required?

false

Position?

named

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, and -OutVariable. For more information, type, "get-help about_commonparameters".

 

INPUT TYPE

PSSnapInInfo.Name

 

RETURN TYPE

PSSnapInInfo object

 

NOTES

 

For more information, type "Get-Help Remove-PSSnapIn -detailed". For technical information, type "Get-Help Remove-PSSnapIn -full".

 

Remove-PSSnapIn does not check the version of Windows PowerShell version before removing a snap-in from the console. If a snap-in cannot be removed, a warning appears and the command fails.

 

To save the configuration of the current console, including snap-ins that you have added and removed, use Export-Console. To find the name of the current console, use the $console variable, which is automatically updated with the name of the current console when you start Windows PowerShell.

 

When specifying multiple values for a parameter, use commas to separate the values. For example, "<parameter-name> <value1>, <value2>".

 

You can also refer to Remove-PSSnapin by its built-in alias, "rsnp". For more information, see About_Alias.

 

EXAMPLE 1

 

remove-pssnapinn -name Microsoft.Exchange

 

This command removes the Micrsoft.Exchange snap-in from the current console. When the command completes, the cmdlets and providers that the snap-in supported are not available in the console.

 

EXAMPLE 2

 

get-PSSnapIn smp* | remove-PSSnapIn

 

Export-console ConsoleSansSMP.psc1

 

These commands remove the Windows PowerShell snap-ins whose names begin with "Smp" from the current console, and then save the current console.

 

The first command uses the Get-PsSnapincmdlet to get objects representing the snap-ins. The pipeline operator (|) sends the results to the Remove-PsSnapin cmdlet, which removes them from the console. The providers and cmdlets that this snap-in supports are no longer available in the console.

 

When you pipe objects to Remove-PsSnapin, the names of the objects are associated with the Name parameter, which accepts objects from the pipeline that have a Name property.

 

The second command uses the Export-Consolecommand to export the new console configuration to the ConsoleSansSMP.psc1 file. If you use this console file in Windows PowerShell, the Windows PowerShell SMP snap-ins that you removed from the console are not loaded.

 

RELATED LINKS

Add-PSSnapIn

Get-PSSnapIn

Export-Console