Powershell Day 18

Day 18 PSSnapin

Powershell works with cmdlets, and cmdlets are commands from snapins. Means spanin contains  group of commands. so if you want to know what all spanins installed /registered there is a command called get-PSsnapin

We can create cmdlets and spanins to extend the functionality of the existing Powershell to make shell more powerful. But you know there are already so much snapins are available just to understand them and use them may be much enough for now. But always there is a requirement for custom on.

By default there are 5 spanins installed on Powershell Version 1

And added 2 more ie. 7  for Powershell V2.

To get the list of pssnapins. The Get-PSSnapin cmdlets

PS C:\> get-pssnapin

Name        : Microsoft.PowerShell.Core

PSVersion   : 1.0

Description : This Windows PowerShell snap-in contains Windows PowerShell management cmdlets used to manage components of Windows PowerShell.

Name        : Microsoft.PowerShell.Host

PSVersion   : 1.0

Description : This Windows PowerShell snap-in contains cmdlets used by the Windows PowerShell host.

Name        : Microsoft.PowerShell.Management

PSVersion   : 1.0

Description : This Windows PowerShell snap-in contains management cmdlets used to manage Windows components.

Name        : Microsoft.PowerShell.Security

PSVersion   : 1.0

Description : This Windows PowerShell snap-in contains cmdlets to manage Windows PowerShell security.

Name        : Microsoft.PowerShell.Utility

PSVersion   : 1.0

Description : This Windows PowerShell snap-in contains utility Cmdlets used to manipulate data.

They are

  1. Core
  2. Host
  3. Management
  4. Security
  5. Utility

 

  1. Diagnostics (V2)

 

  1. WSMAN.Management (v2)

 

To get the detailed cmdlets containing each snapin

PS C:\>  gcm -type cmdlet | ? { $_.pssnapin -match “Core”}

PS C:\>  gcm -type cmdlet | ? { $_.pssnapin -match “Host”}

And so on.

In previous blog we discussed sql related snapins and associated with their cmdlets

Add-PSSnapin SqlServerCmdletSnapin100

Add-PSSnapin SqlServerProviderSnapin100

*sqlps doesn’t have any cmdlets to get/add/remove snapins

Following snapins are excluded from sqlps

Add-PSSnapin                          

Export-Console                        

Get-PSSnapin                          

Remove-PSSnapin                        

So snapin can be included only for Windows Powershell. As menions in day 17 blog. If we include sql related snapin into windows Powershell we are good to runn the cmdlets which is at sqlps.

Finally if you want to remove the snpain  : “Remove-PSSnapin”

This entry was posted in Powershell and tagged . Bookmark the permalink.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.