It's been a while since my last blog post. I have spent the last few weeks working on a number of projects at work and then enjoyed a long vacation with my family. In between I also taught a 3 day PowerShell course and I wanted to share with you a script I wrote for the class.
One of the questions I am often asked is how do you know what each method or property of a .NET object does? How do you know how to use it?
Well, first thing you do if you're not familiar with the object members is to search for it on a search engine. Most likely you'll get a result which points to its MSDN page. Microsoft's MSDN website is the authoritative site for this kind of information. Performing the search and navigating through the results can take some time when all you want is to get to the MSDN page of the Type, Method or property of an object.
To automate the process I have put up together an advanced function. With Get-MSDNInfo you can get a list of an instnace of a .NET object members and navigate to the member MSDN page, if you're lucky enough then you'll find PowerShell examples ,by MVP Thomas Lee, in the 'Community Content' section at the bottom of each page.
Lets take an example. You have a variable which contains a timer object, let's get a list of the object members:
PS > $timer = New-Object -TypeName System.Timers.Timer
PS > Get-MSDNInfo -InputObject $timer -List
To invoke the MSDN page of the $timer object type we can pass the object to InputObject parameter:
PS > Get-MSDNInfo -InputObject $timer
Or pipe the object to the function to the function:
PS > $timer | Get-MSDNInfo
The following command invokes the page of the AutoReset property.
PS > Get-MSDNInfo -InputObject $timer -MemberType Property -Name AutoReset
For more help and code examples type:
PS > Get-Help Get-MSDNInfo -Full
You can review and download the script from HERE or HERE.