{"id":10171,"date":"2006-06-23T19:28:00","date_gmt":"2006-06-23T19:28:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2006\/06\/23\/leveraging-windows-powershell-type-extensions-to-get-documentation\/"},"modified":"2019-02-18T13:21:38","modified_gmt":"2019-02-18T20:21:38","slug":"leveraging-windows-powershell-type-extensions-to-get-documentation","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/leveraging-windows-powershell-type-extensions-to-get-documentation\/","title":{"rendered":"Leveraging Windows PowerShell Type Extensions to get documentation"},"content":{"rendered":"<p>After just a little use of Windows PowerShell, you quickly learn that you need to pipe objects in the GET-MEMBER utility to understand the capabilities of that object.&nbsp; Get-Member reflects against the object and shows you all of its methods and properties (more as well but that will be a different blog).&nbsp; Get-Member is getting that information from the metadata about the type but the issue is that the metadata doesn&#8217;t have any documenation about what the properties are or what the methods do.&nbsp; Now mostly that doesn&#8217;t matter because it is obvious but occassionally it does.&nbsp; Here is how I handle that problem;<\/p>\n<p>Below is an XML fragment from my MY.TYPES.PS1XML file that gets loaded during startup.&nbsp; In my profile is a line:<\/p>\n<p><font face=\"Courier New\" size=\"1\">Update-TypeData c:\\ps\\My.Types.Ps1xml<\/font><\/p>\n<p>If you want to see an example of how this file needs to be written, you can do the following:<\/p>\n<p><font face=\"Courier New\" size=\"1\">notepad&nbsp; (join-path $pshome types.ps1xml)<\/font><\/p>\n<p>Anyway &#8211; one of my entries is this:<\/p>\n<p><font face=\"Courier New\" size=\"1\">&lt;Type&gt;<br \/>&nbsp;&nbsp;&nbsp; &lt;Name&gt;System.Object&lt;\/Name&gt;<br \/>&nbsp;&nbsp;&nbsp; &lt;Members&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;ScriptMethod&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Name&gt;MSDN&lt;\/Name&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Script&gt;<br \/>if (($global:MSDNViewer -eq $null) -or ($global:MSDNViewer.HWND -eq $null))<br \/>{&nbsp;&nbsp; $global:MSDNViewer = new-object -ComObject InternetExplorer.Application<br \/>}<br \/>$Uri = &#8220;<a href=\"http:\/\/msdn2.microsoft.com\/library\/\">http:\/\/msdn2.microsoft.com\/library\/<\/a>&#8221; + $this.GetType().FullName + &#8220;.ASPX&#8221;<br \/>$global:MSDNViewer.Navigate2($Uri)<br \/>$global:MSDNViewer.Visible = $TRUE<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/Script&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/ScriptMethod&gt;<br \/>&nbsp;&nbsp;&nbsp; &lt;\/Members&gt;<br \/>&lt;\/Type&gt;<\/p>\n<p><\/font><font face=\"Courier New\" size=\"1\"><\/font>&nbsp;<\/p>\n<p><font face=\"Courier New\" size=\"1\">Then I can do things like:<\/font><\/p>\n<p><font face=\"Courier New\" size=\"1\">$d=get-date<br \/>$d.MSDN()<\/font><\/p>\n<p><font face=\"Courier New\" size=\"1\">and it will fire up IE and show the documentation for this type.<br \/>Note that I attached this property to System.Object so absolutely every object now has this method.&nbsp; Pretty cool huh?<\/font><\/p>\n<p><font face=\"Courier New\" size=\"1\">Jeffrey Snover<br \/>Windows PowerShell Architect<br \/>(Can you believe that&nbsp;they actually pay to work on this Windows PowerShell &#8211; is that a deal or what!&nbsp; We&#8217;re still hiring <a href=\"http:\/\/blogs.msdn.com\/powershell\/archive\/2006\/05\/04\/590382.aspx\">http:\/\/blogs.msdn.com\/powershell\/archive\/2006\/05\/04\/590382.aspx<\/a>)<\/font><\/p>\n<p>PSMDTAG:FAQ: How can I find out what an Object can do?<br \/>PSMDTAG:FAQ: How can I get at the MSDN documenation for an object?<br \/>PSMDTAG:TYPEEXTENSION: MSDN Method on System.Object<br \/>PSMDTAG:DOCUMENTATION: Adding a method to all objects to get their MSDN Documentation<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After just a little use of Windows PowerShell, you quickly learn that you need to pipe objects in the GET-MEMBER utility to understand the capabilities of that object.&nbsp; Get-Member reflects against the object and shows you all of its methods and properties (more as well but that will be a different blog).&nbsp; Get-Member is getting [&hellip;]<\/p>\n","protected":false},"author":600,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[27,10,15],"class_list":["post-10171","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-documentation","tag-faq","tag-typeextension"],"acf":[],"blog_post_summary":"<p>After just a little use of Windows PowerShell, you quickly learn that you need to pipe objects in the GET-MEMBER utility to understand the capabilities of that object.&nbsp; Get-Member reflects against the object and shows you all of its methods and properties (more as well but that will be a different blog).&nbsp; Get-Member is getting [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/10171","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/600"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=10171"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/10171\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=10171"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=10171"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=10171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}