Windows Powershell snap-ins provide a mechanism for registering sets of cmdlets and providers with the shell, thus extending the functionality of the shell. A Windows Powershell snap-in can register all the cmdlets and providers in a single assembly, or it can register a specific list of cmdlets and providers.
In either case, your snap-in assembly should be installed into protected directories just as they would be with other operating system programs; otherwise, malicious users could replace your assembly with unsafe code.
Registering all Cmdlets and Windows PowerShell providers in an Assembly
To register all the cmdlets and providers in an assembly, derive your Windows Powershell snap-in class from the PSSnapIn class. When derived from this class, all the cmdlets and providers in the assembly will be registered by your snap-in. For an example of a Windows Powershell snap-in, see Writing a Windows PowerShell Snap-in.
Registering a list of Cmdlets and Windows PowerShell providers
To register a list of cmdlets and providers, derive your Windows Powershell snap-in class from the CustomPSSnapIn class. The Cmdlets and Providers properties of this class specify the specific cmdlets and providers that the snap-in will register. For an example of a custom Windows Powershell snap-in, see Writing a Custom Windows PowerShell Snap-in.
When you derive from CustomPSSnapIn, you can perform the following tasks:
-
Specify cmdlets that are in other assemblies.
-
Specify only those cmdlets and providers that you need from an assembly.
-
Specify specific types and formats.
Registering the Snap-in
See Also