Working with PowerShell Modules

List all installed modules:

PS C:>Get-Module -ListAvailable

ModuleType Name                      ExportedCommands                                                          
---------- ----                      ----------------                                                          
Manifest   ActiveDirectory           {}                                                                        
Manifest   AppLocker                 {}                                                                        
Manifest   BitsTransfer              {}                                                                        
Manifest   FailoverClusters          {}                                                                        
Manifest   GroupPolicy               {}                                                                        
Manifest   NetworkLoadBalancingCl... {}                                                                        
Manifest   PSDiagnostics             {Enable-PSTrace, Enable-WSManTrace, Start-Trace, Disable-PSWSManCombined...
Manifest   TroubleshootingPack       {}                                                                        
PS C:>

List all snap-ins loaded:

PS C:> get-pssnapin | ft -Auto
Name                             PSVersion Description                                                                                                        
----                             --------- -----------                                                                                                        
Microsoft.PowerShell.Diagnostics 2.0       This Windows PowerShell snap-in contains Windows Eventing and Performance Counter cmdlets.                         
Microsoft.WSMan.Management       2.0       This Windows PowerShell snap-in contains cmdlets (such as Get-WSManInstance and Set-WSManInstance) that are used ...
Microsoft.PowerShell.Core        2.0       This Windows PowerShell snap-in contains cmdlets used to manage components of Windows PowerShell.                  
Microsoft.PowerShell.Utility     2.0       This Windows PowerShell snap-in contains utility Cmdlets used to manipulate data.                                  
Microsoft.PowerShell.Host        2.0       This Windows PowerShell snap-in contains cmdlets (such as Start-Transcript and Stop-Transcript) that are provided...
Microsoft.PowerShell.Management  2.0       This Windows PowerShell snap-in contains management cmdlets used to manage Windows components.                     
Microsoft.PowerShell.Security    2.0       This Windows PowerShell snap-in contains cmdlets to manage Windows PowerShell security.                            
Quest.ActiveRoles.ADManagement   1.0       This Windows PowerShell snap-in contains cmdlets to manage Active Directory and Quest ActiveRoles Server.          
WASP                             2.0       The Windows Automation Snapin Project has PowerShell cmdlets for enumerating, moving, and managing application wi...
PS C:>
List all registered snap-ins loaded:

PS C:> gsnp -reg | ft -Auto

Name              PSVersion Description
—-              ——— ———–
CreateShortCut    1.0       Creates shortcuts
Logger            1.0       Registers the CmdLets and Providers in this assembly
SQL-DataBase      1.0       For creating a database,attaching and detaching…
WASP              1.0       The Windows Automation Snapin Project has PowerShell cmdlets for enumerating, moving, an…
WindowsOperations 1.0       performs all window related operations.

PS C:>

Listing all cmdlets in a given snap-in:

PS C:> get-command WASP* | ft -Auto

CommandType Name               Definition
———– —-               ———-
Cmdlet      Get-WindowPosition Get-WindowPosition [-Window] [-Passthru] [-Verbose] [-Debug] [-Error…
Cmdlet      Remove-Window      Remove-Window [-Window] [-Passthru] [-Verbose] [-Debug] [-ErrorActio…
Cmdlet      Select-ChildWindow Select-ChildWindow [-Window] [-Passthru] [-Verbose] [-Debug] [-Error…
Cmdlet      Select-Control     Select-Control [[-Index] ] -Window [-Title ] [-Recurse]…
Cmdlet      Select-Window      Select-Window [[-ProcessName] ] [-ToolWindows] [-Verbose] [-Debug] [-ErrorA…
Cmdlet      Send-Click         Send-Click [[-Left] ] [[-Top] ] [[-Button] ] [-Window]
Cmdlet      Send-Keys          Send-Keys [-Keys] [-Window] [-Passthru] [-Verbose] [-Debug]…
Cmdlet      Set-WindowActive   Set-WindowActive [-Window] [-Passthru] [-Verbose] [-Debug] [-ErrorAc…
Cmdlet      Set-WindowPosition Set-WindowPosition [[-Left]] [[-Top]] [[-Width]] [[-Height] <…

PS C:>

PS C:> get-command | where-object{$_.PSSnapin -match “wasp”} | ft -Auto

CommandType Name               Definition
———– —-               ———-
Cmdlet      Get-WindowPosition Get-WindowPosition [-Window] [-Passthru] [-Verbose] [-Debug] [-Error…
Cmdlet      Remove-Window      Remove-Window [-Window] [-Passthru] [-Verbose] [-Debug] [-ErrorActio…
Cmdlet      Select-ChildWindow Select-ChildWindow [-Window] [-Passthru] [-Verbose] [-Debug] [-Error…
Cmdlet      Select-Control     Select-Control [[-Index] ] -Window [-Title ] [-Recurse]…
Cmdlet      Select-Window      Select-Window [[-ProcessName] ] [-ToolWindows] [-Verbose] [-Debug] [-ErrorA…
Cmdlet      Send-Click         Send-Click [[-Left] ] [[-Top] ] [[-Button] ] [-Window]
Cmdlet      Send-Keys          Send-Keys [-Keys] [-Window] [-Passthru] [-Verbose] [-Debug]…
Cmdlet      Set-WindowActive   Set-WindowActive [-Window] [-Passthru] [-Verbose] [-Debug] [-ErrorAc…
Cmdlet      Set-WindowPosition Set-WindowPosition [[-Left]] [[-Top]] [[-Width]] [[-Height] <…

PS C:>

Loading PS snap-ins:

PS C:> Add-PSSnapin wasp
PS C:>

Re-loading of already loaded snapins is not supported and it gives you below error:

PS C:> Add-PSSnapin wasp
Add-PSSnapin : Cannot add Windows PowerShell snap-in wasp because it is already added. Verify the name of the snap-in and try again.
At line:1 char:13
+ Add-PSSnapin  <<<< wasp
PS C:>

Powershell 1.0 snapins doesn’t load in Powershell 2.0 unless they are updated/enhanced for PS2.0

PS C:> Add-PSSnapin sql-database
Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version 2.
At line:1 char:13
+ Add-PSSnapin <<<<  sql-database
+ CategoryInfo          : InvalidArgument: (sql-database:String) [Add-PSSnapin], PSArgumentException
+ FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand

PS C:>

List all snap-ins by it’s providers:

PS C:> get-psprovider| format-list name, pssnapin
Name     : WSMan
PSSnapIn : Microsoft.WSMan.Management

Name     : Alias
PSSnapIn : Microsoft.PowerShell.Core

Name     : Environment
PSSnapIn : Microsoft.PowerShell.Core

Name     : FileSystem
PSSnapIn : Microsoft.PowerShell.Core

Name     : Function
PSSnapIn : Microsoft.PowerShell.Core

Name     : Registry
PSSnapIn : Microsoft.PowerShell.Core

Name     : Variable
PSSnapIn : Microsoft.PowerShell.Core

Name     : Certificate
PSSnapIn : Microsoft.PowerShell.Security

Name     : ActiveDirectory
PSSnapIn :
PS C:>

List all cmdlets related to a module/snap-in:

PS C:> get-command -module WASP | ft -auto
CommandType Name               Definition                                                                                                                     
----------- ----               ----------                                                                                                                     
Cmdlet      Get-WindowPosition Get-WindowPosition [-Window]  [-Passthru] [-Verbose] [-Debug] [-ErrorAction ] [-WarningActi...
Cmdlet      Remove-Window      Remove-Window [-Window]  [-Passthru] [-Verbose] [-Debug] [-ErrorAction ] [-WarningAction  [-Passthru] [-Verbose] [-Debug] [-ErrorAction ] [-WarningActi...
Cmdlet      Select-Control     Select-Control [[-Index] ] -Window  [-Title ] [-Recurse] [-Verbose] [-Debug] [-ErrorAction ] [-ToolWindows] [-Verbose] [-Debug] [-ErrorAction ] [-WarningActio...
Cmdlet      Send-Click         Send-Click [[-Left] ] [[-Top] ] [[-Button] ] [-Window]  [-AltButton] [-ShiftButton...
Cmdlet      Send-Keys          Send-Keys [-Keys]  [-Window]  [-Passthru] [-Verbose] [-Debug] [-ErrorAction ] [-War...
Cmdlet      Set-WindowActive   Set-WindowActive [-Window]  [-Passthru] [-Verbose] [-Debug] [-ErrorAction ] [-WarningAction...
Cmdlet      Set-WindowPosition Set-WindowPosition [[-Left] ] [[-Top] ] [[-Width] ] [[-Height] ] [-Window]  [-Res...
PS C:>

More to follow …


Leave a Reply

Your email address will not be published. Required fields are marked *