{"id":422,"date":"2009-10-07T13:39:00","date_gmt":"2009-10-07T17:39:00","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/2009\/10\/out-notepad-redux\/"},"modified":"2009-10-07T13:56:42","modified_gmt":"2009-10-07T17:56:42","slug":"out-notepad-redux","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/scripting\/422\/out-notepad-redux\/","title":{"rendered":"Out-Notepad Redux"},"content":{"rendered":"<p>I got some great comments and suggestion on my original version of <a href=\"http:\/\/jdhitsolutions.com\/blog\/2009\/10\/out-notepad\/\" target=\"_blank\">Out-Notepad<\/a>, which should work just find on PowerShell v1.0 or 2.0. However, because v2.0 has such terrific features I decided to rework my function into a PowerShell v2.0 only version that also incorporates a few new features.<\/p>\n<p> <!--more-->  <\/p>\n<p>The function now includes help, which I always like, and is much more like a cmdlet now.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2009\/10\/captured_Image.png.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px\" title=\"captured_Image.png\" border=\"0\" alt=\"captured_Image.png\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2009\/10\/captured_Image.png_thumb.png\" width=\"324\" height=\"182\" \/><\/a> <\/p>\n<p>Even though I expect most people will be happy with Notepad.exe, a few will want to specify an alternate text editor. I added a \u2013editor parameter so you can specify a program. You can use an alias or filename, but it must be something that <strong><a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/dd347726.aspx\" target=\"_blank\">Get-Command<\/a> <\/strong>can find because if it can\u2019t verify the editor, then the function defaults back to Notepad.exe. I could have added the validation code to the parameter, but it\u2019s a little ugly and not very friendly if validation fails. My approach is a little more gentle and doesn\u2019t slow you down. You can see it in the revised code for the function.<\/p>\n<div style=\"border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px\" id=\"codeSnippetWrapper\">\n<pre style=\"border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px\" id=\"codeSnippet\">Function Out-Notepad {<br \/><span style=\"color: #008000\">#requires -version 2.0<\/span><br \/><br \/><br \/>&lt;<span style=\"color: #008000\">#<\/span><br \/>.Synopsis<br \/>    Pipe PowerShell output to a temp file and open the file <span style=\"color: #0000ff\">in<\/span> Notepad or an editor of your choice<br \/>.Description<br \/>    This <span style=\"color: #0000ff\">function<\/span> creates a temporary file from pipelined input and opens <span style=\"color: #0000ff\">in<\/span> <span style=\"color: #0000ff\">in<\/span> a text editor of<br \/>    your choice. The <span style=\"color: #0000ff\">default<\/span> is Notepad.exe but you can use -editor to specify the filename and path<br \/>    <span style=\"color: #0000ff\">for<\/span> any text editor. The temp file will be deleted after closing the text editor. If you want to <br \/>    save the output you<span style=\"color: #006080\">'ll need to give it a new name.<br \/>.Parameter InputObject<br \/>    Any pipelined input<br \/>.Parameter Editor<br \/>    The file name and path, if necessary, to any text editor of your choice. You can also use any<br \/>    command aliases that you have defined.<br \/><br \/>.Example<br \/>    PS C:\\&gt; ps | out-notepad<br \/>    <br \/>    Take the output from Get-Process and send it to Notepad.<br \/>.Example<br \/>    PS C:\\&gt; get-wmiobject win32_logicaldisk | Select * | out-notepad -editor nplus<br \/>    <br \/>    Output from the Get-WMIObject expression is sent to the temp file and opened with Notepad++<br \/>    which has been defined with an alias of nplus<br \/>.Inputs<br \/>    Accepts pipelined input<br \/>.Outputs<br \/>    None<br \/>           <br \/>.Link<br \/>   Out-File<br \/>   Out-Printer<br \/>   OUt-GridView<br \/>      <br \/>.Notes<br \/> NAME:      Out-Notepad<br \/> VERSION:   2.0<br \/> AUTHOR:    Jeffery Hicks http:\/\/jdhitsolutions.com\/blog<br \/> LASTEDIT:  10\/7\/2009<br \/><br \/>  ****************************************************************<br \/>  * DO NOT USE IN A PRODUCTION ENVIRONMENT UNTIL YOU HAVE TESTED *<br \/>  * THOROUGHLY IN A LAB ENVIRONMENT. USE AT YOUR OWN RISK.  IF   *<br \/>  * YOU DO NOT UNDERSTAND WHAT THIS SCRIPT DOES OR HOW IT WORKS, *<br \/>  * DO NOT USE IT OUTSIDE OF A SECURE, TEST ENVIRONMENT.         *<br \/>  ****************************************************************<br \/>#&gt;<br \/><br \/>[CmdletBinding()]<br \/><br \/>Param (<br \/>    [Parameter(ValueFromPipeline=$True,Position=0,Mandatory=$True,HelpMessage=&quot;Pipelined input.&quot;)] <br \/>    [object[]]$InputObject,<br \/>    <br \/>    [Parameter(<br \/>     ValueFromPipeline=$False, Mandatory=$False,HelpMessage=&quot;The filename and path to your text editor of choice.&quot;)] <br \/>     [string]$Editor=&quot;Notepad.exe&quot;<br \/><br \/>    )<br \/><br \/><br \/>    Begin {<br \/>        Write-Debug &quot;Beginning&quot;<br \/>        Write-Verbose &quot;Beginning&quot;<br \/>        #get a temporary filename<br \/>        Write-Debug &quot;Getting the temp filename&quot;<br \/>        Write-Verbose &quot;Getting the temp filename&quot;<br \/>        $tempfile=[System.IO.Path]::GetTempFileName()<br \/>        <br \/>        Write-Debug &quot;Temp filename is $tempfile&quot;<br \/>        Write-Verbose &quot;Temp filename is $tempfile&quot;<br \/>        #initialize a placeholder array<br \/>        $data=@()<br \/>        <br \/>        #validate -editor value if other than the default<br \/>        if ($Editor -ne &quot;Notepad.exe&quot;) {<br \/>            Write-Verbose &quot;Validating -editor value $editor&quot;<br \/>            Write-Debug &quot;Validating -editor value $editor&quot;<br \/>            #Get-Command might return more than one entry <br \/>            Get-Command $Editor -ea SilentlyContinue | foreach {<br \/>                Write-Debug $_.definition<br \/>                $editorpath=$_.Definition<br \/>            }<br \/>                      <br \/>         if ($editorpath -AND (Test-Path $editorPath) ) {<br \/>                Write-Debug &quot;Command definition for $editor is $editorPath&quot;<br \/>                Write-Verbose &quot;Command definition for $editor is $editorPath&quot;<br \/>                <br \/>            }<br \/>          else {<br \/>                Write-Warning &quot;Can'<\/span>t find a command path <span style=\"color: #0000ff\">for<\/span> $editor. Defaulting to Notepad.exe<span style=\"color: #006080\">&quot;<br \/>                $Editor=&quot;<\/span>Notepad.exe<span style=\"color: #006080\">&quot;<br \/>            }<br \/>        }<br \/>        <br \/>    } #end Begin scriptblock<br \/>    <br \/>    Process {<br \/>       #save incoming objects to a variable<br \/>       if ($InputObject) {<br \/>         $data+=$InputObject<br \/>        }<br \/>       else  {<br \/>           $data+=$_<br \/>        }<br \/>    } #end Process scriptblock<br \/>    <br \/>    End {<br \/>    <br \/>        Write-Debug &quot;<\/span>Writing data to $tempfile<span style=\"color: #006080\">&quot;<br \/>        Write-Verbose &quot;<\/span>Writing data to $tempfile<span style=\"color: #006080\">&quot;<br \/>        #write data to the temp file<br \/>        $data | Out-File $tempfile<br \/>        <br \/>        #open the tempfile with the specified editor and monitor the process<br \/>        Write-Debug &quot;<\/span>Opening $tempfile with $editor<span style=\"color: #006080\">&quot;<br \/>        Write-Verbose &quot;<\/span>Opening $tempfile with $editor<span style=\"color: #006080\">&quot;<br \/>        <br \/>        #wait for the editor to close because it may have a lock on the file<br \/>        #once closed the temp file can then be deleted.<br \/><br \/>        Start-Process $Editor $tempfile -wait<br \/>        <br \/>        #sleep for 3 seconds before continuing on with the script. Some editors like<br \/>        #Write.exe will actually launch another process, wordpad.exe, in which case<br \/>        #command will return to the script almost immediately, deleting the temp file<br \/>        #before the editor has had a chance to open it. <br \/>        Write-Verbose &quot;<\/span>Sleeping <span style=\"color: #0000ff\">for<\/span> 3 seconds<span style=\"color: #006080\">&quot;<br \/>        sleep 3<br \/>         <br \/>                <br \/>        #Delete the temp file. It should still exist but we'll use an IF statement just to be neat about it.<br \/>         <br \/>        if (Test-Path $tempfile) {<br \/>            Write-Debug &quot;<\/span>Deleting $tempfile<span style=\"color: #006080\">&quot;<br \/>            Write-Verbose &quot;<\/span>Deleting $tempfile<span style=\"color: #006080\">&quot;<br \/>       <br \/>            del $tempfile<br \/>         }<br \/><br \/>        Write-Debug &quot;<\/span>Exiting<span style=\"color: #006080\">&quot;<br \/>        Write-Verbose &quot;<\/span>Exiting&quot;<br \/>    } <span style=\"color: #008000\">#end End scriptblock<\/span><br \/><br \/>} <span style=\"color: #008000\">#end Function<\/span><br \/><\/pre>\n<p><\/div>\n<p>The function uses cmdlet binding so you can use \u2013Debug or \u2013Verbose since I\u2019ve coded for those parameters.<\/p>\n<p>Thanks to a comment from Alex, I revised the code for getting the temp file name. I knew there was a way with the .NET framework but I couldn\u2019t remember and didn\u2019t have the energy at the time to dig it up. <\/p>\n<p>Using <strong>$tempfile=[System.IO.Path]::GetTempFileName()<\/strong> creates a complete filename in the %TEMP% folder.<\/p>\n<p>The other major change is that I use <strong><a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/dd347667.aspx\" target=\"_blank\">Start-Process<\/a><\/strong> to launch the editor using the \u2013wait parameter to tell PowerShell to wait until the process finishes. Once you close Notepad, or whatever, the script sleeps for 3 seconds (I\u2019ll explain why in a moment) and then the temp file is deleted.<\/p>\n<p>The reason for the sleep is that during development I was testing (on Windows 7) using Wordpad which is started by using Write.exe. However, PowerShell wasn\u2019t waiting as I expected and was deleting the file before Wordpad had a chance to open it. Thanks to <a href=\"http:\/\/www.leeholmes.com\/blog\/\" target=\"_blank\">Lee Holmes<\/a> for digging into this for me, Write.exe launches Wordpad.exe and then exits so <strong>Start-Process<\/strong> is in fact waiting for Write.exe to finish. It has no idea that the process launched another process. My solution was to add the 3 second sleep. The downside, small though it is, is that even using the default, PowerShell will sleep for 3 seconds after you close Notepad before exiting. I can live it and I trust you can too.<\/p>\n<div style=\"padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px\" id=\"scid:F60BB8FA-6F02-4999-8F5E-9DD4E92C4DA7:0f8a8635-5a23-4925-b801-a9fc2e5633be\" class=\"wlWriterEditableSmartContent\">\n<div><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2009\/10\/OutNotepadv2.txt\" target=\"_blank\">Download the PowerShell v2.0 script here.<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>I got some great comments and suggestion on my original version of Out-Notepad, which should work just find on PowerShell v1.0 or 2.0. However, because v2.0 has such terrific features I decided to rework my function into a PowerShell v2.0 only version that also incorporates a few new features.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[75,8],"tags":[32,534,540],"class_list":["post-422","post","type-post","status-publish","format-standard","hentry","category-powershell-v2-0","category-scripting","tag-functions","tag-powershell","tag-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Out-Notepad Redux &#8226; The Lonely Administrator<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/scripting\/422\/out-notepad-redux\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Out-Notepad Redux &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"I got some great comments and suggestion on my original version of Out-Notepad, which should work just find on PowerShell v1.0 or 2.0. However, because v2.0 has such terrific features I decided to rework my function into a PowerShell v2.0 only version that also incorporates a few new features.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/scripting\/422\/out-notepad-redux\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2009-10-07T17:39:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2009-10-07T17:56:42+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2009\/10\/captured_Image.png_thumb.png\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/422\\\/out-notepad-redux\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/422\\\/out-notepad-redux\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Out-Notepad Redux\",\"datePublished\":\"2009-10-07T17:39:00+00:00\",\"dateModified\":\"2009-10-07T17:56:42+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/422\\\/out-notepad-redux\\\/\"},\"wordCount\":437,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/422\\\/out-notepad-redux\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2009\\\/10\\\/captured_Image.png_thumb.png\",\"keywords\":[\"functions\",\"PowerShell\",\"Scripting\"],\"articleSection\":[\"PowerShell v2.0\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/422\\\/out-notepad-redux\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/422\\\/out-notepad-redux\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/422\\\/out-notepad-redux\\\/\",\"name\":\"Out-Notepad Redux &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/422\\\/out-notepad-redux\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/422\\\/out-notepad-redux\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2009\\\/10\\\/captured_Image.png_thumb.png\",\"datePublished\":\"2009-10-07T17:39:00+00:00\",\"dateModified\":\"2009-10-07T17:56:42+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/422\\\/out-notepad-redux\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/422\\\/out-notepad-redux\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/422\\\/out-notepad-redux\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2009\\\/10\\\/captured_Image.png_thumb.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2009\\\/10\\\/captured_Image.png_thumb.png\",\"width\":\"324\",\"height\":\"182\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/422\\\/out-notepad-redux\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell v2.0\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell-v2-0\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Out-Notepad Redux\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Out-Notepad Redux &#8226; The Lonely Administrator","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jdhitsolutions.com\/blog\/scripting\/422\/out-notepad-redux\/","og_locale":"en_US","og_type":"article","og_title":"Out-Notepad Redux &#8226; The Lonely Administrator","og_description":"I got some great comments and suggestion on my original version of Out-Notepad, which should work just find on PowerShell v1.0 or 2.0. However, because v2.0 has such terrific features I decided to rework my function into a PowerShell v2.0 only version that also incorporates a few new features.","og_url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/422\/out-notepad-redux\/","og_site_name":"The Lonely Administrator","article_published_time":"2009-10-07T17:39:00+00:00","article_modified_time":"2009-10-07T17:56:42+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2009\/10\/captured_Image.png_thumb.png","type":"","width":"","height":""}],"author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/422\/out-notepad-redux\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/422\/out-notepad-redux\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Out-Notepad Redux","datePublished":"2009-10-07T17:39:00+00:00","dateModified":"2009-10-07T17:56:42+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/422\/out-notepad-redux\/"},"wordCount":437,"commentCount":0,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/422\/out-notepad-redux\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2009\/10\/captured_Image.png_thumb.png","keywords":["functions","PowerShell","Scripting"],"articleSection":["PowerShell v2.0","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/422\/out-notepad-redux\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/422\/out-notepad-redux\/","url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/422\/out-notepad-redux\/","name":"Out-Notepad Redux &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/422\/out-notepad-redux\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/422\/out-notepad-redux\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2009\/10\/captured_Image.png_thumb.png","datePublished":"2009-10-07T17:39:00+00:00","dateModified":"2009-10-07T17:56:42+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/422\/out-notepad-redux\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/422\/out-notepad-redux\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/422\/out-notepad-redux\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2009\/10\/captured_Image.png_thumb.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2009\/10\/captured_Image.png_thumb.png","width":"324","height":"182"},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/422\/out-notepad-redux\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell v2.0","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-v2-0\/"},{"@type":"ListItem","position":2,"name":"Out-Notepad Redux"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":467,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/467\/get-numberedcontent-v2\/","url_meta":{"origin":422,"position":0},"title":"Get-NumberedContent v2","author":"Jeffery Hicks","date":"October 22, 2009","format":false,"excerpt":"I wasn\u2019t completely satisfied with the updated version of my Get-NumberedContent function. You should still refer to the earlier post for details on how to use the function. But I had some issues with the previous version and realized there were a few bugs. I\u2019ve since updated the Get-NumberedContent function.\u2026","rel":"","context":"In &quot;PowerShell v2.0&quot;","block_context":{"text":"PowerShell v2.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-v2-0\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":418,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/418\/out-notepad\/","url_meta":{"origin":422,"position":1},"title":"Out-Notepad","author":"Jeffery Hicks","date":"October 6, 2009","format":false,"excerpt":"Maybe this isn\u2019t the most earth shattering PowerShell function you\u2019ll ever come across, but it saves me a few keystrokes. There are times when I want to see the results of PowerShell expression but the console output is insufficient. I want to see the results in a text file opened\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1344,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1344\/what-made-the-scripting-games-easier\/","url_meta":{"origin":422,"position":2},"title":"What Made the Scripting Games Easier","author":"Jeffery Hicks","date":"April 14, 2011","format":false,"excerpt":"I can easily say that the quantity and caliber of script submissions in this year's Scripting Games has been amazing. I congratulate all of you on your hard work and trust it will pay off. I'd say a primary goal is education. Not only will you pick up tips from\u2026","rel":"","context":"In &quot;PowerShell ISE&quot;","block_context":{"text":"PowerShell ISE","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-ise\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/04\/editorsurvey-4-300x201.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":343,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/343\/revising-windows-powershell-tfm-3rd\/","url_meta":{"origin":422,"position":3},"title":"Revising Windows PowerShell: TFM 3rd","author":"Jeffery Hicks","date":"August 21, 2009","format":false,"excerpt":"I know there was some concern related to my departure from SAPIEN about the status of the Windows PowerShell: TFM book. You\u2019ll be happy to know that Don Jones and I are both involved now in the final revisions.\u00a0 SAPIEN is very committed to this project and supporting the PowerShell\u2026","rel":"","context":"In &quot;Books&quot;","block_context":{"text":"Books","link":"https:\/\/jdhitsolutions.com\/blog\/category\/books\/"},"img":{"alt_text":"header_sapien_press","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2009\/08\/header_sapien_press.gif?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":493,"url":"https:\/\/jdhitsolutions.com\/blog\/writing\/493\/pre-orders-for-windows-powershell-2-0-tfm\/","url_meta":{"origin":422,"position":4},"title":"Pre-Orders for Windows PowerShell 2.0: TFM","author":"Jeffery Hicks","date":"November 9, 2009","format":false,"excerpt":"SAPIEN Press is now taking pre-orders for the latest edition of the popular Windows PowerShell: TFM. The new version, Windows PowerShell 2.0: TFM is really the 3rd edition of our original book. Don Jones and I have worked very hard to make this the most comprehensive PowerShell resource you can\u2026","rel":"","context":"In &quot;Books&quot;","block_context":{"text":"Books","link":"https:\/\/jdhitsolutions.com\/blog\/category\/books\/"},"img":{"alt_text":"PShell_Version_2_cover_100res","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2009\/11\/PShell_Version_2_cover_100res.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":748,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/748\/get-your-free-scripting-toolkit\/","url_meta":{"origin":422,"position":5},"title":"Get Your Free Scripting Toolkit","author":"Jeffery Hicks","date":"July 29, 2010","format":false,"excerpt":"If you were at this year's TechEd event in New Orleans, I hoped you dropped by the SAPIEN Technologies booth and picked up your free Scripting Toolkit. What's that you say? Check it out on the SAPIEN blog and then download your free copy.","rel":"","context":"In &quot;Books&quot;","block_context":{"text":"Books","link":"https:\/\/jdhitsolutions.com\/blog\/category\/books\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/422","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=422"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/422\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=422"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=422"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=422"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}