This is the built-in help made by Microsoft for the command 'Add-PSSnapin', in PowerShell version 5 - as retrieved from
Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.
For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.
Adds one or more Windows PowerShell snap-ins to the current session.
Add-PSSnapin [-Name] <String> [-PassThru] [<CommonParameters>]
The Add-PSSnapin cmdlet adds registered Windows PowerShell snap-ins to the current session. After the snap-ins are added, you can use the cmdlets and providers that the
snap-ins support in the current session.
To add the snap-in to all future Windows PowerShell sessions, add an Add-PSSnapin command to your Windows PowerShell profile. For more information, see about_Profiles.
Beginning in Windows PowerShell 3.0, the core commands that are included in Windows PowerShell are packaged in modules. The exception is Microsoft.PowerShell.Core, which is
a snap-in (PSSnapin). By default, only the Microsoft.PowerShell.Core snap-in is added to the session. Modules are imported automatically on first use and you can use the
Import-Module cmdlet to import them.
Online Version: http://go.microsoft.com/fwlink/p/?linkid=289570
-------------------------- EXAMPLE 1 --------------------------
PS C:\>add-PSSnapIn Microsoft.Exchange, Microsoft.Windows.AD
This command adds the Microsoft Exchange and Active Directory snap-ins to the current session.
-------------------------- EXAMPLE 2 --------------------------
PS C:\>get-pssnapin -registered | add-pssnapin -passthru
This command adds all of the registered Windows PowerShell snap-ins to the session. It uses the Get-PSSnapin cmdlet 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 session. The PassThru parameter returns objects that
represent each of the added snap-ins.
-------------------------- EXAMPLE 3 --------------------------
The first command gets snap-ins that have been added to the current session, including the snap-ins that are installed with Windows PowerShell. In this example,
ManagementFeatures is not returned. This indicates that it has not been added to the session.
The second command gets snap-ins that have been registered on your system (including those that have already been added to the session). It does not include the snap-ins
that are installed with Windows PowerShell.In this case, the command does not return any snap-ins. This indicates that the ManagementFeatures snapin has not been registered
on the system.
PS C:\>get-pssnapin -registered
The third command creates an alias, "installutil", for the path to the InstallUtil tool in .NET Framework.
PS C:\>set-alias installutil $env:windir\Microsoft.NET\Framework\v2.0.50727\installutil.exe
The fourth command uses the InstallUtil tool to register the snap-in. The command specifies the path to ManagementCmdlets.dll, the file name or "module name" of the snap-in.
PS C:\>installutil C:\Dev\Management\ManagementCmdlets.dll
The fifth command is the same as the second command. This time, you use it to verify that the ManagementCmdlets snap-in is registered.
PS C:\>get-pssnapin -registered
The sixth command uses the Add-PSSnapin cmdlet to add the ManagementFeatures snap-in to the session. It specifies the name of the snap-in, ManagementFeatures, not the file
PS C:\>add-pssnapin ManagementFeatures
To verify that the snap-in is added to the session, the seventh command uses the Module parameter of the Get-Command cmdlet. It displays the items that were added to the
session by a snap-in or module.
PS C:\>get-command -module ManagementFeatures
You can also use the PSSnapin property of the object that the Get-Command cmdlet returns to find the snap-in or module in which a cmdlet originated. The eighth command uses
dot notation to find the value of the PSSnapin property of the Set-Alias cmdlet.
PS C:\>(get-command set-alias).pssnapin
This example demonstrates the process of registering a snap-in on your system and then adding it to your session. It uses ManagementFeatures, a fictitious snap-in
implemented in a file called ManagementCmdlets.dll.