I have hacked together a way to achieve these results, but its not pretty and its requires additional coding. I used get-help to learn more about Powershell Redirection
Get-Help about_redirection -ShowWindow
I found this little gem here:
WINDOWS POWERSHELL REDIRECTION OPERATORS
The redirection operators enable you to send particular types of output
to files and to the success output stream.
The Windows PowerShell redirection operators use the following characters
to represent each output type:
* All output
1 Success output
2 Errors
3 Warning messages
4 Verbose output
5 Debug messages
6 Informational messages
NOTE: The All (*), Warning (3), Verbose (4) and Debug (5) redirection operators were introduced
in Windows PowerShell 3.0; the Information (6) redirection operator was introduced
in Windows PowerShell 5.0. They do not work in earlier versions of Windows PowerShell.
The Windows PowerShell redirection operators are as follows.
Operator Description Example
-------- ---------------------- ------------------------------
> Sends output to the Get-Process > Process.txt
specified file.
>> Appends the output to dir *.ps1 >> Scripts.txt
the contents of the
specified file.
2> Sends errors to the Get-Process none 2> Errors.txt
specified file.
2>> Appends errors to Get-Process none 2>> Save-Errors.txt
the contents of the
specified file.
2>&1 Sends errors (2) and Get-Process none, Powershell 2>&1
success output (1)
to the success
output stream.
3> Sends warnings to the Write-Warning "Test!" 3> Warnings.txt
specified file.
3>> Appends warnings to Write-Warning "Test!" 3>> Save-Warnings.txt
the contents of the
specified file.
3>&1 Sends warnings (3) and function Test-Warning
success output (1) { Get-Process PowerShell;
to the success Write-Warning "Test!" }
output stream. Test-Warning 3>&1
4> Sends verbose output to Import-Module * -Verbose 4> Verbose.txt
the specified file.
4>> Appends verbose output Import-Module * -Verbose 4>> Save-Verbose.txt
to the contents of the
specified file.
4>&1 Sends verbose output (4) Import-Module * -Verbose 4>&1
and success output (1)
to the success output
stream.
5> Sends debug messages to Write-Debug "Starting" 5> Debug.txt
the specified file.
5>> Appends debug messages Write-Debug "Saving" 5>> Save-Debug.txt
to the contents of the
specified file.
5>&1 Sends debug messages (5) function Test-Debug
and success output (1) { Get-Process PowerShell
to the success output Write-Debug "PS" }
stream. Test-Debug 5>&1
6> Sends informational Write-Information "Here they are" 6> Info.txt
messages to a specified
file
6>> Appends informational Write-Information "Nothing found" 6>> Info.txt
messages to the contents
of a specified file.
6>&1 Sends informational function Test-Info
messages and success { Get-Process P*
output to the success Write-Information "Here you go" }
output stream. Test-Info 6>&1
*> Sends all output types function Test-Output
to the specified file. { Get-Process PowerShell, none
Write-Warning "Test!"
*>> Appends all output types Write-Verbose "Test Verbose"
to the contents of the Write-Debug "Test Debug" }
specified file.
Test-Output *> Test-Output.txt
*>&1 Sends all output types Test-Output *>> Test-Output.txt
(*) to the success output Test-Output *>&1
stream.
The syntax of the redirection operators is as follows:
<input> <operator> [<path>\]<file>
That gave me a couple of ideas. One, write transcript manipulation into your scripts and two, make use of the “Write-Information” Cmdlet. See below for an example.
# This produces output that the OP requested
$hereString = @'
Start-Transcript C:\Temp\Test_transcript.txt
Write-Information -MessageData "Write-Output 'This is a test. Will this command be redirected, or only the output?'"
Write-Output "This is a test. Will this command be redirected, or only the output?"
Stop-Transcript
'@
$hereString | Out-File C:\TEMP\test_redirect.ps1 -Force
Start-Process cmd -ArgumentList "/C powershell.exe -file C:\temp\test_redirect.ps1" -Wait
notepad C:\Temp\Test_transcript.txt
…truncated…
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
Transcript started, output file is C:\Temp\Test_transcript.txt
INFO: Write-Output ‘This is a test. Will this command be redirected, or only the output?’
This is a test. Will this command be redirected, or only the output?
Windows PowerShell transcript end
End time: 20181221160639
Again, not pretty but technically achieves your desired outcome.