PowerShell – Out-Notepad function

There are many out-notepad functions out there but for some reason I found them either too long or too complicated so here is mine, short and sweet:

Function Out-Notepad {
 [CmdletBinding()]
    Param
      (  
        [Parameter(Mandatory=$true,
        ValueFromPipeline=$true,
        Position=0)]
        $StrText
       )
$fso=new-object -com scripting.filesystemobject
$filename=$fso.GetTempName()
$tempfile=Join-Path $env:temp $filename
$strText | Out-File $tempfile
notepad $tempfile
#tidy up
sleep 3
if (Test-Path $tempfile) {del $tempfile}
}

Leave a Reply

Your email address will not be published. Required fields are marked *

2 + 6 =

This site uses Akismet to reduce spam. Learn how your comment data is processed.