{"id":8641,"date":"2012-07-22T00:01:00","date_gmt":"2012-07-22T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2012\/07\/22\/weekend-scripter-use-powershell-to-find-and-explore-net-framework-classes\/"},"modified":"2012-07-22T00:01:00","modified_gmt":"2012-07-22T00:01:00","slug":"weekend-scripter-use-powershell-to-find-and-explore-net-framework-classes","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/weekend-scripter-use-powershell-to-find-and-explore-net-framework-classes\/","title":{"rendered":"Weekend Scripter: Use PowerShell to Find and Explore .NET Framework Classes"},"content":{"rendered":"<p><strong>Summary<\/strong>:&nbsp;<span>The Microsoft Scripting Guy, Ed Wilson, shows how to use Windows PowerShell to find and to explore .NET Framework classes.<\/span><\/p>\n<h2>PoshReflectionExplorer? Or not.<\/h2>\n<p>Microsoft Scripting Guy, Ed Wilson, is here. Well the day finally arrived. This morning the Scripting Wife dropped me off at the airport, and I begin my trek across the United States to Seattle Washington for the Microsoft internal conference, TechReady 15. I do not know if I have mentioned it or not, but there are 38 Windows PowerShell sessions going on this week at TechReady 15. Dude, I can tell you that I will have my work cut out for me attempting to see all of them. So I have my laptop running the latest build of Windows 8, and the customer preview of Office 2013, and I got a free upgrade to First Class, and 5 &frac12; hours of free time during the flight to enjoy. Sweet.\nI seem to remember an email or a comment on a recent Hey, Scripting Guy! Blog post about exploring .NET Framework classes via Windows PowerShell. I wrote a Windows PowerShell script to do this very thing more than four years ago when I was working on the Windows PowerShell Scripting Guide book for Microsoft Press. I am not going to show you the script (which is a rather ugly Windows PowerShell 1.0 script), but I will show you the techniques that I used in the script to create my explorer.\n&nbsp;<\/p>\n<h2>First find the current appdomain<\/h2>\n<p>The first thing to do is to find the current appdomain. There is one used by the Windows PowerShell console, and a different one used for the Windows PowerShell ISE. To find the current appdomain, use the static <strong>currentdomain<\/strong> property from the system.appdomain .NET Framework class. (By the way, this works in Windows PowerShell 3.0 as well). First, the current appdomain for the Windows PowerShell console.<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; [appdomain]::CurrentDomain<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">FriendlyName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : DefaultDomain<\/p>\n<p style=\"padding-left: 30px\">Id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 1<\/p>\n<p style=\"padding-left: 30px\">ApplicationDescription :<\/p>\n<p style=\"padding-left: 30px\">BaseDirectory&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : C:WINDOWSsystem32WindowsPowerShellv1.0<\/p>\n<p style=\"padding-left: 30px\">DynamicDirectory&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">RelativeSearchPath&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">SetupInformation&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : System.AppDomainSetup<\/p>\n<p style=\"padding-left: 30px\">ShadowCopyFiles&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : False\n&nbsp;\nNow, using the same command in the Windows PowerShell ISE, you can see different results.<\/p>\n<p style=\"padding-left: 30px\">PS C:Usersed.IAMMRED&gt; [appdomain]::currentdomain<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">FriendlyName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : PowerShell_ISE.exe<\/p>\n<p style=\"padding-left: 30px\">Id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 1<\/p>\n<p style=\"padding-left: 30px\">ApplicationDescription :<\/p>\n<p style=\"padding-left: 30px\">BaseDirectory&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : C:Windowssystem32WindowsPowerShellv1.0<\/p>\n<p style=\"padding-left: 30px\">DynamicDirectory&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">RelativeSearchPath&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">SetupInformation&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : System.AppDomainSetup<\/p>\n<p style=\"padding-left: 30px\">ShadowCopyFiles&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : False\n&nbsp;\nThe <strong>currentdomain<\/strong> static property returns a system.appdomain object. This object contains a number of methods in addition to the displayed properties. I can find this information by piping the results from the <strong>currentdomain<\/strong> static property to the <strong>Get-Member<\/strong> cmdlet. This command is shown here.<\/p>\n<p style=\"padding-left: 30px\">[appdomain]::CurrentDomain | get-member\nThe method I want to use is the <strong>getassemblies <\/strong>method. The <strong>getassemblies <\/strong>method is not a static method, but because the <strong>currentdomain<\/strong> static property returns a system.appdomain object. I can call the method directly from that object. Here is the command and associated output from the Windows PowerShell console (on a Windows PowerShell 2.0 machine. In Windows PowerShell 3.0, the versions are all v4.0.xxxxx).<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; [appdomain]::currentdomain.GetAssemblies()<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">GAC &nbsp;&nbsp;&nbsp;Version&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Location<\/p>\n<p style=\"padding-left: 30px\">&#8212;&nbsp;&nbsp;&nbsp; &#8212;&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8211;<\/p>\n<p style=\"padding-left: 30px\">True&nbsp;&nbsp; v2.0.50727&nbsp;&nbsp;&nbsp;&nbsp; C:WindowsMicrosoft.NETFramework64v2.0.50727mscorlib.dll<\/p>\n<p style=\"padding-left: 30px\">True&nbsp;&nbsp; v2.0.50727&nbsp;&nbsp;&nbsp;&nbsp; C:WindowsassemblyGAC_MSILMicrosoft.PowerShell.ConsoleHo&#8230;<\/p>\n<p style=\"padding-left: 30px\">True&nbsp;&nbsp; v2.0.50727&nbsp;&nbsp;&nbsp;&nbsp; C:WindowsassemblyGAC_MSILSystem2.0.0.0__b77a5c561934e0&#8230;<\/p>\n<p style=\"padding-left: 30px\">True&nbsp;&nbsp; v2.0.50727&nbsp;&nbsp;&nbsp;&nbsp; C:WindowsassemblyGAC_MSILSystem.Management.Automation1&#8230;<\/p>\n<p style=\"padding-left: 30px\">True&nbsp;&nbsp; v2.0.50727&nbsp;&nbsp;&nbsp;&nbsp; C:WindowsassemblyGAC_MSILMicrosoft.PowerShell.Commands&#8230;.<\/p>\n<p style=\"padding-left: 30px\">True&nbsp;&nbsp; v2.0.50727&nbsp;&nbsp;&nbsp;&nbsp; C:WindowsassemblyGAC_MSILSystem.Core3.5.0.0__b77a5c561&#8230;<\/p>\n<p style=\"padding-left: 30px\">True&nbsp;&nbsp; v2.0.50727&nbsp;&nbsp;&nbsp;&nbsp; C:WindowsassemblyGAC_MSILSystem.Configuration.Install2&#8230;<\/p>\n<p style=\"padding-left: 30px\">True&nbsp;&nbsp; v2.0.50727&nbsp;&nbsp;&nbsp;&nbsp; C:WindowsassemblyGAC_MSILMicrosoft.WSMan.Management1.0&#8230;<\/p>\n<p style=\"padding-left: 30px\">True&nbsp;&nbsp; v2.0.50727&nbsp;&nbsp;&nbsp;&nbsp; C:WindowsassemblyGAC_64System.Transactions2.0.0.0__b77&#8230;<\/p>\n<p style=\"padding-left: 30px\">True&nbsp;&nbsp; v2.0.50727&nbsp;&nbsp;&nbsp;&nbsp; C:WindowsassemblyGAC_MSILMicrosoft.PowerShell.Commands&#8230;.<\/p>\n<p style=\"padding-left: 30px\">True&nbsp;&nbsp; v2.0.50727&nbsp;&nbsp;&nbsp;&nbsp; C:WindowsassemblyGAC_MSILMicrosoft.PowerShell.Commands&#8230;.<\/p>\n<p style=\"padding-left: 30px\">True&nbsp;&nbsp; v2.0.50727&nbsp;&nbsp;&nbsp;&nbsp; C:WindowsassemblyGAC_MSILMicrosoft.PowerShell.Security&#8230;<\/p>\n<p style=\"padding-left: 30px\">True&nbsp;&nbsp; v2.0.50727&nbsp;&nbsp;&nbsp;&nbsp; C:WindowsassemblyGAC_MSILSystem.Xml2.0.0.0__b77a5c5619&#8230;<\/p>\n<p style=\"padding-left: 30px\">True&nbsp;&nbsp; v2.0.50727&nbsp;&nbsp;&nbsp;&nbsp; C:WindowsassemblyGAC_MSILSystem.Management2.0.0.0__b03&#8230;<\/p>\n<p style=\"padding-left: 30px\">True&nbsp;&nbsp; v2.0.50727&nbsp;&nbsp;&nbsp;&nbsp; C:WindowsassemblyGAC_MSILSystem.DirectoryServices2.0.0&#8230;<\/p>\n<p style=\"padding-left: 30px\">True&nbsp;&nbsp; v2.0.50727&nbsp;&nbsp;&nbsp;&nbsp; C:WindowsassemblyGAC_64System.Data2.0.0.0__b77a5c56193&#8230;<\/p>\n<p style=\"padding-left: 30px\">True&nbsp;&nbsp; v2.0.50727&nbsp;&nbsp;&nbsp;&nbsp; C:WindowsassemblyGAC_MSILSystem.Configuration2.0.0.0__&#8230;<\/p>\n<p style=\"padding-left: 30px\">True&nbsp;&nbsp; v2.0.50727&nbsp;&nbsp;&nbsp;&nbsp; C:WindowsassemblyGAC_MSILSystem.Security2.0.0.0__b03f5&#8230;<\/p>\n<p style=\"padding-left: 30px\">True&nbsp;&nbsp; v2.0.50727&nbsp;&nbsp;&nbsp;&nbsp; C:WindowsassemblyGAC_MSILSystem.Data.SqlXml2.0.0.0__b7&#8230;\nThe <strong>getassemblies<\/strong> method returns instances of the System.Reflection.Assembly .NET Framework class. This class contains a number of very interesting methods and properties. The output from <strong>Get-Member<\/strong> on the returned system.reflection.assembly .NET framework class is shown here.<i><\/i><\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; [appdomain]::currentdomain.GetAssemblies() | Get-Member<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp; TypeName: System.Reflection.Assembly<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MemberType Definition<\/p>\n<p style=\"padding-left: 30px\">&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;-<\/p>\n<p style=\"padding-left: 30px\">ModuleResolve&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Event&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Reflection.ModuleResolveEventHandler &#8230;<\/p>\n<p style=\"padding-left: 30px\">CreateInstance&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Object CreateInstance(string typeName&#8230;<\/p>\n<p style=\"padding-left: 30px\">Equals&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; bool Equals(System.Object o)<\/p>\n<p style=\"padding-left: 30px\">GetCustomAttributes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Object[] GetCustomAttributes(bool inh&#8230;<\/p>\n<p style=\"padding-left: 30px\">GetExportedTypes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; type[] GetExportedTypes()<\/p>\n<p style=\"padding-left: 30px\">GetFile&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;Method&nbsp;&nbsp;&nbsp;&nbsp; System.IO.FileStream GetFile(string name)<\/p>\n<p style=\"padding-left: 30px\">GetFiles&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.IO.FileStream[] GetFiles(), System.IO&#8230;<\/p>\n<p style=\"padding-left: 30px\">GetHashCode&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; int GetHashCode()<\/p>\n<p style=\"padding-left: 30px\">GetLoadedModules&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Reflection.Module[] GetLoadedModules(&#8230;<\/p>\n<p style=\"padding-left: 30px\">GetManifestResourceInfo&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Reflection.ManifestResourceInfo GetMa&#8230;<\/p>\n<p style=\"padding-left: 30px\">GetManifestResourceNames&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; string[] GetManifestResourceNames()<\/p>\n<p style=\"padding-left: 30px\">GetManifestResourceStream Method&nbsp;&nbsp;&nbsp;&nbsp; System.IO.Stream GetManifestResourceStream(t&#8230;<\/p>\n<p style=\"padding-left: 30px\">GetModule&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Reflection.Module GetModule(string name)<\/p>\n<p style=\"padding-left: 30px\">GetModules&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Reflection.Module[] GetModules(), Sys&#8230;<\/p>\n<p style=\"padding-left: 30px\">GetName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Reflection.AssemblyName GetName(), Sy&#8230;<\/p>\n<p style=\"padding-left: 30px\">GetObjectData&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Void GetObjectData(System.Runtime.Ser&#8230;<\/p>\n<p style=\"padding-left: 30px\">GetReferencedAssemblies&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Reflection.AssemblyName[] GetReferenc&#8230;<\/p>\n<p style=\"padding-left: 30px\">GetSatelliteAssembly&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Reflection.Assembly GetSatelliteAssem&#8230;<\/p>\n<p style=\"padding-left: 30px\">GetType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; type GetType(string name), type GetType(stri&#8230;<\/p>\n<p style=\"padding-left: 30px\">GetTypes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; type[] GetTypes()<\/p>\n<p style=\"padding-left: 30px\">IsDefined&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method &nbsp;&nbsp;&nbsp;&nbsp;bool IsDefined(type attributeType, bool inhe&#8230;<\/p>\n<p style=\"padding-left: 30px\">LoadModule&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Reflection.Module LoadModule(string m&#8230;<\/p>\n<p style=\"padding-left: 30px\">ToString&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; string ToString()<\/p>\n<p style=\"padding-left: 30px\">CodeBase&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.String CodeBase {get;}<\/p>\n<p style=\"padding-left: 30px\">EntryPoint&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.Reflection.MethodInfo EntryPoint {get;}<\/p>\n<p style=\"padding-left: 30px\">EscapedCodeBase&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.String EscapedCodeBase {get;}<\/p>\n<p style=\"padding-left: 30px\">Evidence&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.Security.Policy.Evidence Evidence {get;}<\/p>\n<p style=\"padding-left: 30px\">FullName&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Property&nbsp;&nbsp; System.String FullName {get;}<\/p>\n<p style=\"padding-left: 30px\">GlobalAssemblyCache&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.Boolean GlobalAssemblyCache {get;}<\/p>\n<p style=\"padding-left: 30px\">HostContext&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.Int64 HostContext {get;}<\/p>\n<p style=\"padding-left: 30px\">ImageRuntimeVersion&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.String ImageRuntimeVersion {get;}<\/p>\n<p style=\"padding-left: 30px\">Location&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.String Location {get;}<\/p>\n<p style=\"padding-left: 30px\">ManifestModule&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.Reflection.Module ManifestModule {get;}<\/p>\n<p style=\"padding-left: 30px\">ReflectionOnly&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.Boolean ReflectionOnly {get;}\nFor instance, one thing you might be interested in finding out is if the assembly resides in the Global Assembly Cache (GAC). In the Windows PowerShell 2.0 console, all assemblies are in fact in the GAC. But in the Windows PowerShell 2.0 ISE, and in the Windows PowerShell 3.0 console, this is not the case. If you find yourself using an assembly very often, you might want the assembly in the GAC. Here is how to find assemblies from the current appdomain that are not in the GAC.<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; [appdomain]::currentdomain.GetAssemblies() | where {!($_.globalassemblycache)}<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">GAC&nbsp;&nbsp;&nbsp; Version&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Location&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n<p style=\"padding-left: 30px\">&#8212;&nbsp;&nbsp;&nbsp; &#8212;&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8211;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n<p style=\"padding-left: 30px\">False&nbsp; v2.0.50727&nbsp;&nbsp;&nbsp;&nbsp; C:Windowssystem32WindowsPowerShellv1.0PowerShell_ISE.exe&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n<p style=\"padding-left: 30px\">False&nbsp; v2.0.50727&nbsp;&nbsp;&nbsp;&nbsp; C:Windowssystem32WindowsPowerShellv1.0CompiledComposition.Microsoft.Po&#8230;\n&nbsp;\nEach loaded .NET Framework assembly contributes .NET Framework classes. To see the classes exposed by the assembly, you can use the <i>gettypes <\/i>method from the System.Reflection.Assembly class returned by the <i>GetAssemblies <\/i>method from the <i>appdomain <\/i>class. As you might expect, there are numerous .NET Framework classes. Interestingly enough, the <i>more <\/i>filter does not appear to work consistently when working interactively via the Windows PowerShell console, and it does not work at all in the Windows PowerShell ISE. So you might want to consider redirecting the output to a text file. One thing that will help is to sort the output by basetype. Here is the command to do that.<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; [appdomain]::currentdomain.GetAssemblies() | Foreach-Object {$_.gettypes()} | sort basetype\nDo not expect to quickly find exotic, little known, unused .NET Framework classes. Most of the output, for the IT Pro will be rather pedestrian, lots of error classes, lots of enum, lots of structures, and the like. The output headings appear here:<\/p>\n<p style=\"padding-left: 30px\">IsPublic IsSerial Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BaseType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n<p style=\"padding-left: 30px\">&#8212;&#8212;&#8211; &#8212;&#8212;&#8211; &#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&#8212;&#8212;&#8211;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\nThe first couple of pages of output do not event list a base type. Then, when we get to the first grouping of types that do expose a base type, the output is disappointing. Here are the first three lines from that section.<\/p>\n<p style=\"padding-left: 30px\">False&nbsp;&nbsp;&nbsp; True&nbsp;&nbsp;&nbsp;&nbsp; ModuleLoadExceptionHandlerException&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;CrtImplementationDeta&#8230;<\/p>\n<p style=\"padding-left: 30px\">False&nbsp;&nbsp;&nbsp; False&nbsp;&nbsp;&nbsp; CSharpMemberAttributeConverter&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Microsoft.CSharp.CShar&#8230;<\/p>\n<p style=\"padding-left: 30px\">False&nbsp;&nbsp;&nbsp; False&nbsp;&nbsp;&nbsp; CSharpTypeAttributeConverter&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Microsoft.CSharp.CShar&#8230;<\/p>\n<p style=\"padding-left: 30px\">False&nbsp;&nbsp;&nbsp; False&nbsp;&nbsp;&nbsp; WmiAsyncCmdletHelper&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Microsoft.PowerShell.C&#8230;\nWhat is going on here? Remember that last year, I wrote a Hey Scripting Guy! blog entitled, <span style=\"font-family: arial, helvetica, sans-serif\"><span style=\"color: #0000ff\"><a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2011\/11\/20\/change-a-powershell-preference-variable-to-reveal-hidden-data.aspx\" target=\"_blank\">Change a PowerShell Preference Variable to Reveal Hidden Data<\/a>.<\/span><\/span>&nbsp;Well, if you do not remember it, don&rsquo;t worry, I did not remember the title either. But I did a search for <span style=\"font-family: arial, helvetica, sans-serif\"><span style=\"color: #0000ff\"><a href=\"http:\/\/blogs.technet.com\/controlpanel\/blogs\/posteditor.aspx\/&lt;a%20href=%22\/search\/searchresults.aspx?q=preference%20variables&amp;amp;sections=7618%22&gt;preference%20variables&lt;\/a&gt;,\" target=\"_blank\">preference variables,<\/a><\/span> <\/span>and I found it on the first try.<i> <\/i>Basically, what you need to do is change the $FormatEnumerationLimit preference variable. By default, the enumeration limit value is 4; and so after four items. it does not use any more space. I like to change it to 20.\nBut unfortunately, this does not solve the problem. The problem here is that the .NET Framework class names are extremely long&#8230;in some cases, really long. Therefore, using the basic redirection arrow does not help capture all the output. In this case, you need to move beyond the defaults and specify a custom width for the output. The best way to do this is to use the <strong>Out-File<\/strong> cmdlet. By setting the width to 180, you will capture most (but not all) of the really long .NET Framework class names. (Each time you make the file wider, you also increase the file size and make the file a bit more difficult to use.) For example, a width of 500 characters will create a file about 8 MB in size. A width of 180 will be around 3.5 MB in size (with over 10,000 lines in it). Here is the command I used.<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; [appdomain]::currentdomain.GetAssemblies() | % {$_.gettypes()} | sort basetype | Out-File -FilePath c:fsogettypes.txt -Width 180 &ndash;Append\nNow that you have the list, you can peruse it at your leisure. Use <strong>Get-Member<\/strong> or MSDN to help you find things. I can tell you, from experience that it can spend a very long time looking through stuff. Have fun, and I will talk to you on Monday.\nI invite you to follow me on <span style=\"font-family: arial, helvetica, sans-serif\"><a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\"><span style=\"color: #0000ff\">Twitter<\/span><\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\"><span style=\"color: #0000ff\">Facebook<\/span><\/a><\/span>. If you have any questions, send email to me at <span style=\"font-family: arial, helvetica, sans-serif\"><a href=\"http:\/\/blogs.technet.commailto:scripter@microsoft.com\" target=\"_blank\"><span style=\"color: #0000ff\">scripter@microsoft.com<\/span><\/a><\/span>, or post your questions on the <span style=\"font-family: arial, helvetica, sans-serif\"><a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\"><span style=\"color: #0000ff\">Official Scripting Guys Forum<\/span><\/a>.<\/span> See you tomorrow. Until then, peace.<\/p>\n<p style=\"margin-left: 0in\"><b><span style=\"font-family: 'Segoe UI','sans-serif';font-size: 10pt\">Ed Wilson, Microsoft Scripting Guy<\/p>\n<p><\/span><\/b><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary:&nbsp;The Microsoft Scripting Guy, Ed Wilson, shows how to use Windows PowerShell to find and to explore .NET Framework classes. PoshReflectionExplorer? Or not. Microsoft Scripting Guy, Ed Wilson, is here. Well the day finally arrived. This morning the Scripting Wife dropped me off at the airport, and I begin my trek across the United States [&hellip;]<\/p>\n","protected":false},"author":597,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[66,3,4,61,45],"class_list":["post-8641","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-net-framework","tag-scripting-guy","tag-scripting-techniques","tag-weekend-scripter","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary:&nbsp;The Microsoft Scripting Guy, Ed Wilson, shows how to use Windows PowerShell to find and to explore .NET Framework classes. PoshReflectionExplorer? Or not. Microsoft Scripting Guy, Ed Wilson, is here. Well the day finally arrived. This morning the Scripting Wife dropped me off at the airport, and I begin my trek across the United States [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/8641","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/597"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=8641"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/8641\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=8641"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=8641"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=8641"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}