{"id":5711,"date":"2008-07-17T19:03:00","date_gmt":"2008-07-17T19:03:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2008\/07\/17\/dude-wheres-my-manual\/"},"modified":"2019-02-18T13:13:06","modified_gmt":"2019-02-18T20:13:06","slug":"dude-wheres-my-manual","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/dude-wheres-my-manual\/","title":{"rendered":"Dude, Where&#039;s My Manual?"},"content":{"rendered":"<p><span><font size=\"3\"><font face=\"Calibri\"><\/p>\n<p class=\"MsoNormal\"><span lang=\"EN\">Windows PowerShell comes with a lot of help files and documents, but, somehow, my favorite and most-frequently-used help is the help that&nbsp; I get by typing &#8220;Get-Help&#8221; in the console.<\/span><\/p>\n<p class=\"MsoNormal\"><span lang=\"EN\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\"><span lang=\"EN\">And I have always wondered why this help is not readily available as a&nbsp; single document, ready to be viewed, searched, and printed. Well, now it is, with this simple Get-Manual script. <\/span><\/p>\n<p class=\"MsoNormal\"><span lang=\"EN\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\"><span lang=\"EN\">This script merges all of the about_* help content with cmdlet help, and puts it into one pretty formatted Microsoft Word document (.doc). Once you have this document, you can search it for specific content. Or, you can print it and have some enjoyable reading while sitting in your favorite armchair by the fireplace during the long winter evenings \ud83d\ude42<\/span><\/p>\n<p class=\"MsoNormal\"><span lang=\"EN\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\"><span lang=\"EN\"><strong>Updated 09\/30\/2008<\/strong>: Now the script not only collects the about_*.txt files, but it also includes the content of cmdlet help. It is also more localization-friendly. (Thanks to Markus for his brilliant CDATA suggestion!) <\/span><\/p>\n<p class=\"MsoNormal\"><\/font><\/font><\/span><span><font size=\"3\">&nbsp;<\/font><\/span><\/p>\n<p class=\"MsoNormal\"><span>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/span><\/p>\n<p class=\"MsoNormal\"><span>&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\"><span># Get-Manual.ps1<\/span><\/p>\n<p class=\"MsoNormal\"><span># This script merges the text from all about* files<br \/># in the Windows PowerShell installation directory ($pshome)<br \/># and help content from cmdlet help<br \/># into one MS Word document file and opens the file that was created.<\/span><\/p>\n<p class=\"MsoNormal\"><span># Setting up helper functions.<\/span><\/p>\n<p class=\"MsoNormal\"><span>function MakeHeading($text)<br \/>{<br \/>&nbsp;return &#8216;&lt;w:p&gt;&lt;w:pPr&gt;&lt;w:pStyle w:val=&#8221;Heading1&#8243; \/&gt;&lt;\/w:pPr&gt;&lt;w:r&gt;&lt;w:t&gt;&lt;![CDATA[&#8216; + $text + &#8216;]]&gt;&lt;\/w:t&gt;&lt;\/w:r&gt;&lt;\/w:p&gt;&#8217;<br \/>}<\/span><\/p>\n<p class=\"MsoNormal\"><span>function MakeParagraph($text)<br \/>{<br \/>&nbsp;return &#8216;&lt;w:p&gt;&lt;w:r&gt;&lt;w:t&gt;&lt;![CDATA[&#8216; + $text + &#8216;]]&gt;&lt;\/w:t&gt;&lt;\/w:r&gt;&lt;\/w:p&gt;&#8217;<br \/>}<\/span><\/p>\n<p><span><\/p>\n<p class=\"MsoNormal\"># Set the file name for generated WordML document.<br \/>$doc = &#8220;PowerShell Get-Help Content.doc&#8221;<\/p>\n<p class=\"MsoNormal\">&#8220;Generating MS Word document&#8230;&#8221;<\/p>\n<p class=\"MsoNormal\">$sb=new-object system.text.stringbuilder<\/p>\n<p class=\"MsoNormal\">$null = $sb.Append(@&#8217;<br \/>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243; standalone=&#8221;yes&#8221; ?&gt;<br \/>&lt;?mso-application progid=&#8221;Word.Document&#8221;?&gt;<br \/>&lt;w:wordDocument<br \/>&nbsp; xmlns:w=&#8221;<a href=\"http:\/\/schemas.microsoft.com\/office\/word\/2003\/wordml\">http:\/\/schemas.microsoft.com\/office\/word\/2003\/wordml<\/a>&#8220;<br \/>&nbsp; xmlns:wx=&#8221;<a href=\"http:\/\/schemas.microsoft.com\/office\/word\/2003\/auxHint\">http:\/\/schemas.microsoft.com\/office\/word\/2003\/auxHint<\/a>&#8220;<br \/>&nbsp;w:macrosPresent=&#8221;no&#8221; w:embeddedObjPresent=&#8221;no&#8221; w:ocxPresent=&#8221;no&#8221; xml:space=&#8221;preserve&#8221;&gt;<br \/>&nbsp;&lt;w:styles&gt;<br \/>&nbsp;&nbsp;&lt;w:versionOfBuiltInStylenames w:val=&#8221;4&#8243; \/&gt;<br \/>&nbsp;&nbsp;&lt;w:style w:type=&#8221;paragraph&#8221; w:default=&#8221;on&#8221; w:styleId=&#8221;Normal&#8221;&gt;<br \/>&nbsp;&nbsp;&nbsp;&lt;w:name w:val=&#8221;Normal&#8221; \/&gt;<br \/>&nbsp;&nbsp;&nbsp;&lt;w:rPr&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;w:rFonts w:ascii=&#8221;Lucida Console&#8221; w:h-ansi=&#8221;Lucida Console&#8221; w:cs=&#8221;Lucida Console&#8221; \/&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;w:sz w:val=&#8221;24&#8243; \/&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;w:sz-cs w:val=&#8221;24&#8243; \/&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;w:lang w:val=&#8221;EN-US&#8221; w:fareast=&#8221;ZH-CN&#8221; w:bidi=&#8221;AR-SA&#8221; \/&gt;<br \/>&nbsp;&nbsp;&nbsp;&lt;\/w:rPr&gt;<br \/>&nbsp;&nbsp;&lt;\/w:style&gt;<br \/>&nbsp;&nbsp;&lt;w:style w:type=&#8221;paragraph&#8221; w:styleId=&#8221;Heading1&#8243;&gt;<br \/>&nbsp;&nbsp;&nbsp;&lt;w:name w:val=&#8221;heading 1&#8243; \/&gt;<br \/>&nbsp;&nbsp;&nbsp;&lt;wx:uiName wx:val=&#8221;Heading 1&#8243; \/&gt;<br \/>&nbsp;&nbsp;&nbsp;&lt;w:basedOn w:val=&#8221;Normal&#8221; \/&gt;<br \/>&nbsp;&nbsp;&nbsp;&lt;w:next w:val=&#8221;Normal&#8221; \/&gt;<br \/>&nbsp;&nbsp;&nbsp;&lt;w:pPr&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;w:pStyle w:val=&#8221;Heading1&#8243; \/&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;w:keepNext \/&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;w:spacing w:before=&#8221;240&#8243; w:after=&#8221;120&#8243; \/&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;w:outlineLvl w:val=&#8221;0&#8243; \/&gt;<br \/>&nbsp;&nbsp;&nbsp;&lt;\/w:pPr&gt;<br \/>&nbsp;&nbsp;&nbsp;&lt;w:rPr&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;w:b \/&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;w:b-cs \/&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;w:kern w:val=&#8221;32&#8243; \/&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;w:sz w:val=&#8221;32&#8243; \/&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;w:sz-cs w:val=&#8221;32&#8243; \/&gt;<br \/>&nbsp;&nbsp;&nbsp;&lt;\/w:rPr&gt;<br \/>&nbsp;&nbsp;&lt;\/w:style&gt;<br \/>&nbsp;&lt;\/w:styles&gt;<br \/>&nbsp;&lt;w:docPr&gt;<br \/>&nbsp;&nbsp;&lt;w:view w:val=&#8221;web&#8221;\/&gt;<br \/>&nbsp;&nbsp;&lt;w:zoom w:val=&#8221;full-page&#8221; w:percent=&#8221;100&#8243;\/&gt;<br \/>&nbsp;&lt;\/w:docPr&gt;<br \/>&nbsp;&lt;w:body&gt;<br \/>&#8216;@)<\/p>\n<p class=\"MsoNormal\"># Get all content from about* help files.<br \/>$filter = &#8220;about*.txt&#8221;<br \/>dir $pshome -filter $filter -recurse | %{<br \/>&nbsp;$null = $sb.Append((MakeHeading($_)))<br \/>&nbsp;<br \/>&nbsp;get-content $_.FullName | %{<br \/>&nbsp;&nbsp;$null = $sb.Append((MakeParagraph($_)))<br \/>&nbsp;}<br \/>}<\/p>\n<p class=\"MsoNormal\"># Get all content from cmdlet help.<br \/>get-command | %{<br \/>&nbsp;$null = $sb.Append((MakeHeading($_.Name + &#8216; Cmdlet&#8217;)))<\/p>\n<p class=\"MsoNormal\">&nbsp;$helpText = $_ | get-help -full | Out-String<\/p>\n<p class=\"MsoNormal\">&nbsp;if ($helpText -eq &#8220;&#8221;) { $helpText= &#8216;&lt;no help found&gt;&#8217; }<\/p>\n<p class=\"MsoNormal\">&nbsp;$helpText -split &#8220;`n&#8221; | %{<br \/>&nbsp;&nbsp;$null = $sb.Append((MakeParagraph($_)))<br \/>&nbsp;}<br \/>}<\/p>\n<p class=\"MsoNormal\">$null = $sb.Append(&#8220;&lt;\/w:body&gt;&lt;\/w:wordDocument&gt;&#8221;)<\/p>\n<p class=\"MsoNormal\"># Write generated string to document file.<br \/>$sb.ToString() | out-file $doc -encoding UTF8<\/p>\n<p class=\"MsoNormal\"># Open the resulting file in MS-Word.<br \/>$null = [System.Diagnostics.Process]::Start(&#8220;$pwd\\$doc&#8221;)<\/p>\n<p class=\"MsoNormal\">&#8220;Done&#8221;<br \/><\/span><span>&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\"><span>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/span><\/p>\n<p class=\"MsoNormal\"><span><font face=\"Calibri\" size=\"3\">&nbsp;<\/font><\/span><\/p>\n<p class=\"MsoNormal\"><span><font size=\"3\"><font face=\"Calibri\">Vladimir Averkin<\/font><\/font><\/span><\/p>\n<p class=\"MsoNormal\"><span><font size=\"3\"><font face=\"Calibri\">Windows PowerShell Test<\/font><\/font><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Windows PowerShell comes with a lot of help files and documents, but, somehow, my favorite and most-frequently-used help is the help that&nbsp; I get by typing &#8220;Get-Help&#8221; in the console. &nbsp; And I have always wondered why this help is not readily available as a&nbsp; single document, ready to be viewed, searched, and printed. Well, [&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":[],"class_list":["post-5711","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"blog_post_summary":"<p>Windows PowerShell comes with a lot of help files and documents, but, somehow, my favorite and most-frequently-used help is the help that&nbsp; I get by typing &#8220;Get-Help&#8221; in the console. &nbsp; And I have always wondered why this help is not readily available as a&nbsp; single document, ready to be viewed, searched, and printed. Well, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/5711","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=5711"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/5711\/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=5711"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=5711"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=5711"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}