Where do messages from scripts go in Reflect?


Author
Message
Patrick O'Keefe
Patrick O'Keefe
Expert
Expert (879 reputation)Expert (879 reputation)Expert (879 reputation)Expert (879 reputation)Expert (879 reputation)Expert (879 reputation)Expert (879 reputation)Expert (879 reputation)Expert (879 reputation)Expert (879 reputation)
Group: Forum Members
Posts: 604, Visits: 4.1K
The PS scripts that Reflect generates contain many Write-Host and a few Write-Warning cmdlets.  Where does this output go?

The equivalent VBS scripts don't include equivalent statements.  Assuming this output goes somewhere that Reflect users could find, would the VBS stdout.WriteLine and stderr.WriteLine write to those same locations?  Or would I use WScript.Echo?  Both VBS and PS are foreign languages to me, but I can fumble around in VBS a bit more easily.

jphughan
jphughan
Macrium Evangelist
Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)
Group: Forum Members
Posts: 14K, Visits: 85K
Write-Host output only goes to the console, which doesn’t exist in a background scheduled task. Write-Warning output goes to the console and can be piped to a text file if you call the script in a way that does that, e.g. “.\MyScript.ps1 > C:\Log.txt”.

Similar to the point I made in your other thread about the Elevate function, that’s meant more for cases where the script is called interactively, not via scheduled task.

On a somewhat related note, Macrium relatively recently offered a way to tweak scripts to allow output generated by Reflect itself to be captured: https://knowledgebase.macrium.com/plugins/servlet/mobile?contentId=23397605#content/view/23397605

However, that would not affect the output behavior of other lines in the script that you’re asking about. The only way I know of to capture Write-Host output would be to run Start-Transcript upfront or else change all Write-Host cmdlets to Write-Output, although the latter will break parameters such as custom colors.
Edited 27 July 2022 4:48 AM by jphughan
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Login

Explore
Messages
Mentions
Search