<# .Synopsis Display output in Notepad Alan dot Kaplan at VA dot gov, alan at akaplan dot com .DESCRIPTION This function create a temporary file for output, displays the output in notepad, then deletes the temp file .EXAMPLE Get-ADUser $env:USERNAME | Out-Notepad #> Function Out-Notepad { [CmdletBinding()] Param ( # StrText help description [Parameter(Mandatory=$true, ValueFromPipeline=$true, Position=0)] $StrText ) #Make sure file input is string, trim leading and trailing spaces $strText = $($strText| out-string).Trim() #Get temp filename $tempFile = [System.IO.Path]::GetTempFileName() #put input into file Set-Content -value $strText -Path $tempfile -Force #wait a second sleep -Seconds 1 #Use VB.Interaction Shell/Run with wait Add-Type -assemblyname Microsoft.visualBasic $command = "NOTEPAD.EXE $tempfile" $newProc=[Microsoft.VisualBasic.Interaction]::Shell($command,1,$True) #after notepad is closed, temp file is deleted del $tempFile #cleanup Remove-Variable tempFile,command,NewProc,strText }