Add-PSSnapin

 

SYNOPSIS

Adds one or more Windows PowerShell snap-ins to the current console.

 

SYNTAX

Add-PSSnapin [-name] <string[]> [-passThru] [<CommonParameters>]

 

DETAILED DESCRIPTION

The Add-PSSnapIn cmdlet adds one or more Windows PowerShell snap-ins to the current console. After the snap-ins are added, you can use the cmdlets and providers that the snap-in supports in the current console.

 

PARAMETERS

 

-name <string[]>

The unique name of each PSSnapIn to add to the current console; for example Microsoft.Exchange or MyCompany.User. The parameter name is optional.

 

Required?

true

Position?

1

Default value

 

Accept pipeline input?  

true (ByPropertyName)

Accept wildcard characters? 

true

 

-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

 

<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

PSSnapIn info object

 

NOTES

 

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

 

For detailed information about snap-ins in Windows PowerShell, type "get-help about_pssnapins". For help with creating a Windows PowerShell snap-in, see the Windows PowerShell SDK.

 

Add-PSSnapin adds the snap-in only to the current console. To save the current console (with the added snap-in), use Export-Console. Otherwise, the snap-in will not be available if you use the console again.

 

You can add any Windows PowerShell snap-in that has been registered by using the .NET Framework install utility. For details, see the Windows PowerShell SDK. To get a list of snap-ins that are registered on your computer,

type " Get-PsSnapin-registered".

 

Before adding a snap-in, Add-PSSnapIn checks the version of the snap-in to verify that it is compatible with the shell. If the snap-in fails the version check, Windows PowerShell reports an error.

 

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

 

You can also refer to Add-PSSnapIn by its built-in alias, "asnp". For more information, type "get-help About_Alias".

 

EXAMPLE 1

 

add-PSSnapIn Microsoft.Exchange,Microsoft.Windows.AD

 

This command adds the Microsoft Exchange and Microsoft Active Directory Directory Services snap-ins to the current console.

 

EXAMPLE 2

 

get-pssnapin -registered | add-pssnapin -passthru

 

This command adds all of the registered Windows PowerShell snap-ins to the console. It uses the Get-PsSnapincmdlet with the Registered parameter to get objects representing each of the registered snap-ins. The pipeline operator (|) passes the result to Add-PsSnapin, which adds them to the conole. The Passthru parameter passes the object down the pipeline. Because there are no more command in the pipeline, the object are displayed in the console.

 

RELATED LINKS

Get-PSSnapIn

Remove-PSSnapIn

Export-Console