Export (0) Print
Expand All

about_PSSnapins

Updated: May 20, 2009

Applies To: Windows PowerShell 2.0

TOPIC
    about_PSSnapins

SHORT DESCRIPTION
    Describes Windows PowerShell snap-ins and shows how to use and manage them.

LONG DESCRIPTION
    A Windows PowerShell snap-in is a Microsoft .NET Framework assembly that 
    contains Windows PowerShell providers and/or cmdlets. Windows PowerShell 
    includes a set of basic snap-ins, but you can extend the power and value 
    of Windows PowerShell by adding snap-ins that contain providers and cmdlets
    that you create or get from others. 

    When you add a snap-in, the cmdlets and providers that it contains are
    immediately available for use in the current session, but the change
    affects only the current session. 

    To add the snap-in to all future sessions, save it in your Windows
    PowerShell profile. You can also use the Export-Console cmdlet to save
    the snap-in names to a console file and then use it in future sessions.
    You can even save multiple console files, each with a different set of
    snap-ins.


 BUILT-IN SNAP-INS
    Windows PowerShell includes a set of Windows PowerShell snap-ins that 
    contain the built-in providers and cmdlets.

    Microsoft.PowerShell.Core
        Contains providers and cmdlets used to manage the basic features of 
        Windows PowerShell. It includes the FileSystem, Registry, Alias, 
        Environment, Function, and Variable providers and basic cmdlets like
        Get-Help, Get-Command, and Get-History.

    Microsoft.PowerShell.Host
       Contains cmdlets used by the Windows PowerShell host, such as 
       Start-Transcript and Stop-Transcript.

    Microsoft.PowerShell.Management
        Contains cmdlets such as Get-Service and Get-ChildItem that are used to
        manage Windows-based features.

    Microsoft.PowerShell.Security
        Contains cmdlets used to manage Windows PowerShell security, such as 
        Get-Acl, Get-AuthenticodeSignature, and ConvertTo-SecureString.

    Microsoft.PowerShell.Utility
        Contains cmdlets used to manipulate objects and data, such as 
        Get-Member, Write-Host, and Format-List.


 FINDING SNAP-INS
    To get a list of the Windows PowerShell snap-ins on your computer, type:

	get-pssnapin

    To get the snap-in for each Windows PowerShell provider, type: 

        get-psprovider | format-list name, pssnapin

    To get a list of the cmdlets in a Windows PowerShell snap-in, type:

        get-command -module <snap-in_name>


 INSTALLING A SNAP-IN
    The built-in snap-ins are registered in the system and added to the
    default session when you start Windows PowerShell. However, you have to 
    register snap-ins that you create or obtain from others and then add the
    snap-ins to your session.


 REGISTERING A SNAP-IN
    A Windows PowerShell snap-in is a program written in a .NET Framework 
    language that is compiled into a .dll file. To use the providers and 
    cmdlets in a snap-in, you must first register the snap-in (add it to the
    registry). 

    Most snap-ins include an installation program (an .exe or .msi file)
    that registers the .dll file for you. However, if you receive a snap-in as
    a .dll file, you can register it on your system. For more information, see
    "How to Register Cmdlets, Providers, and Host Applications" in the MSDN 
    (Microsoft Developer Network) library at 
    http://go.microsoft.com/fwlink/?LinkID=143619.

    To get all the registered snap-ins on your system or to verify that a
    snap-in is registered, type:

	get-pssnapin -registered


 ADDING THE SNAP-IN TO THE CURRENT SESSION
    To add a registered snap-in to the current session, use the Add-PsSnapin
    cmdlet. For example, to add the Microsoft SQL Server snap-in to the 
    session, type:

	add-pssnapin sql

    After the command is completed, the providers and cmdlets in the snap-in
    are available in the session. However, they are available only in the
    current session unless you save them.


 SAVING THE SNAP-INS
    To use a snap-in in future Windows PowerShell sessions, add the 
    Add-PsSnapin command to your Windows PowerShell profile. Or, export
    the snap-in names to a console file. 

    If you add the Add-PSSnapin command to your profile, it is available
    in all future Windows PowerShell sessions. If you export the names of
    the snap-ins in your session, you can use the export file only when you
    need the snap-ins.

    To add the Add-PsSnapin command to your Windows PowerShell profile,
    open your profile, paste or type the command, and then save the profile.
    For more information, see about_Profiles.

    To save the snap-ins from a session in console file (.psc1), use
    the Export-Console cmdlet. For example, to save the snap-ins in 
    the current session configuration to the NewConsole.psc1 file in the
    current directory, type:

	export-console NewConsole

    For more information, see Export-Console.


 OPENING WINDOWS POWERSHELL WITH A CONSOLE FILE
    To use a console file that includes the snap-in, start Windows PowerShell
    (Powershell.exe) from the command prompt in Cmd.exe or in another
    Windows PowerShell session. Use the PsConsoleFile parameter to specify
    the console file that includes the snap-in. For example, the following
    command starts Windows PowerShell with the NewConsole.psc1 console file:

	powershell.exe -psconsolefile NewConsole.psc1

    The providers and cmdlets in the snapin are now available for use in 
    the session.


 REMOVING A SNAP-IN
    To remove a Windows PowerShell snap-in from the current session, use the
    Remove-PsSnapin cmdlet. For example, to remove the SQL Server
    snap-in from the current session, type:

	remove-pssnapin sql

    This cmdlet removes the snap-in from the session. The snap-in is still
    loaded, but the providers and cmdlets that it supports are no longer
    available. 


SEE ALSO
    Add-PsSnapin
    Get-PsSnapin   
    Remove-PsSnapin
    Export-Console
    Get-Command
    about_Profiles



Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft