Home > Powershell > Get-Help for .Net types in PowerShell

Get-Help for .Net types in PowerShell

February 16th, 2012 Leave a comment Go to comments

One thing I hear people ask about with PowerShell pretty frequently is regarding the fact that reference information for underlying .Net types is not available through the Get-Help cmdlet. While I can certainly understand the frustration, there is unfortunately little that can be done about it since the .Net reference documentation is not included with PowerShell.

While Get-Member can give us an awful lot of information about the methods, properties, and other members of a specific object, you have to jump through a few hoops to make all of the information display in an easy to read format. If you want to see static members you have to change around your call to Get-Member entirely.  The only way to get real reference / help information is to open up the MSDN library and look the information up.

This got me thinking, instead of dealing with all of the MSDN documentation manually, why not just create a script that will open up MSDN for me to the page about the specified type? This isn't a difficult process, but there are many different URLs that the script would have to be aware of to make sure it always loads the correct page that it became a bit messy. Therefore I opted for a much simpler option: just make the script load the MSDN search page with the specified type queried for me.

 

Jump past the break for more info and to download the script

The script allows input in the form of Type, MemberInformation, or just a String. The nice thing with MemberInformation is that you can do something like:

Get-ChildItem | Get-Member | .\Find-TypeReference.ps1

This will send the member information Get-Member returns and will look through it to figure out the data type and then pass it off to the web browser.

Since not every type will be defined in the .Net Framework because some could be third party types that don't exist on MSDN it also allows you to open up Bing instead to do the search. Combine this with the fact that it allows you to specify a string query, and now you have a function that will not only search for type information based on objects piped into it, but also open up a search for just about any query you can think of.

Additionally, this script uses ShouldProcess to make sure you don't pass in hundreds of different types and end up bringing your computer to a crawl by launching too many instances of a web browser for the search page.  Stay tuned for a future post which will talk about ShouldProcess and how to use it in your own scripts.

Download Find-TypeReference.ps1Download Find-TypeReference.ps1

Categories: Powershell Tags:
Share/Save
  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.