A question in the newsgroups about using Windows Forms with PowerShell got me thinking about what assemblies are actually loaded by PowerShell. As I load a number of extra snapins in my profile I decided to step through them and see what extras are loaded
Starting with a pure PowerShell load with no extras we get this
PS> 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.
PS> [appdomain]::currentdomain.getassemblies() | sort -property fullname | format-table fullname
FullName
——–
Microsoft.PowerShell.Commands.Management, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Microsoft.PowerShell.Commands.Utility, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Microsoft.PowerShell.ConsoleHost, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Microsoft.PowerShell.Security, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Configuration.Install, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Management, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
The loaded assemblies are split between the PowerShell and System namespaces.
These next sections will only show the additions in order to highlight what is changing. The listings will show the name of the snapin and the additional assemblies loaded by that snapin.
Adding the PowerShell Community Extensions
Name : Pscx
PSVersion : 1.0
Description : PowerShell Community Extensions (PSCX) base snapin which implements a general purpose set of cmdlets.
ICSharpCode.SharpZipLib, Version=0.85.1.271, Culture=neutral, PublicKeyToken=1b03e6acf1164f73
Pscx, Version=1.1.1.0, Culture=neutral, PublicKeyToken=null
Pscx.Core, Version=1.1.1.0, Culture=neutral, PublicKeyToken=null
PowerGadgets adds a significant number of assemblies
Name : PowerGadgets
PSVersion : 1.0
Description : Generates Charts, Gauges and Maps Gadgets from Windows PowerShell data
Accessibility, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
ChartFX.Designer, Version=7.0.1500.0, Culture=neutral, PublicKeyToken=a1878e2052c08dce
ChartFX.WinForms, Version=7.0.2568.19404, Culture=neutral, PublicKeyToken=a1878e2052c08dce
ChartFX.WinForms.Base, Version=7.0.2568.19286, Culture=neutral, PublicKeyToken=a1878e2052c08dce
PowerGadgets.Commands, Version=1.0.1500.0, Culture=neutral, PublicKeyToken=a1878e2052c08dce
PowerGadgets.Data, Version=1.0.1500.0, Culture=neutral, PublicKeyToken=a1878e2052c08dce
System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
including Windows Forms as shown.
PowerPad also adds Windows Forms assemblies
Name : PowerPad
PSVersion : 1.0
Description : This PowerPad snap-in contains cmdlets to edit and run PSH code snippets.
PowerPad, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Note that PowerPad doesn’t supply a Public Key Token signifying that it hasn’t a strong name
The free sdmgpo cmdlets just add their own assemblies
Name : get-sdmgpo
PSVersion : 1.0
Description : Lists a GPO (or all GPOs) in an AD domain and their properties
get-SDMgpo, Version=1.0.1.41207, Culture=neutral, PublicKeyToken=null
Name : new-sdmgpo
PSVersion : 1.0
Description : Let’s you create new GPOs in a domain
new-SDMgpo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Quest ADcmdlets again just adds its own assembly
Name : Quest.ActiveRoles.ADManagement
PSVersion : 1.0
Description : Registers the CmdLets and Providers in this assembly
Quest.ActiveRoles.ArsPowerShellSnapIn, Version=1.0.4.292, Culture=neutral, PublicKeyToken=null
Finally the OneNote provider
Name : Microsoft.Office.OneNote
PSVersion : 1.0
Description : Provides cmdlets for managing OneNote notebooks.
Microsoft.Office.Interop.OneNote, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c
Microsoft.Office.OneNote.Commands, Version=1.5.0.1, Culture=neutral, PublicKeyToken=null
Note the interop assenmbly that is being loaded. This eanbles access to the OneNote COM objects through .NET code.
If you really want to know what is being loaded on to your system then you need to use
Get-PSSnapin
[appdomain]::currentdomain.getassemblies() | sort -property fullname | format-table fullname
The first command shows the PowerShell snapins that have been loaded and the second shows the .NET assemblies that those snapins load into PowerShell. Knowing this will help when deciding why a particular piece of .NET functionality can’t be accessed.
Pingback: Understanding .NET from the perspective of an IT Professional « Energized About Technology