Having an issue using write-information in a workflow. Hoping i’m doing something silly and someone can point it out!
Its a simple script!
When i set the $InformationPreference in the shell i’m using it will work, but this is a workflow and will run on many random systems. I have tried to set it at the start of the workflow, but it doesn’t see to work. So i commented it out.
Hoping this is not a bug as write-information is supported in a workflow! Cant get any simpler than below!
By default, Write-Information does not output to host, as (as you’ve noticed) InformationPreference is set to SilentlyContinue. It also doesn’t support adding the “PSHOST” tag (unless you use $PSCmdlet.WriteInformation(“Message”, “PSHOST”), though I guess that’s no longer Write-Information).
You can, however, capture it in -InformationVariable and various other methods (Jaykul’s Information module is neat).
Having said that, in PowerShell >5.0 Write-Host is essentially Write-Information with the magic PSHOST tag applied (some handwaving included, here).
Some additional context. This is run in SMA. This will run as part of a parent / child workflow with information being passed between them. Using write-output pollutes the information being passed between the workflows. Using write-host displays nothing either.
I can put a sample parent / child workflow together if that would help demonstrate the issue better?
Here is a sample with write-output / write-information and write-verbose. You can comment whatever it is you want to test against.
Essentially i want test-parent to receive the $value from test-child, and only that value. I want the write-output displayed, but not inside the $value.
I can use write-information, but $InformationPreference = “Continue” must be set for that shell to work I cant seem to set it globally or for all users / shells spawned.
My apologies - I managed to miss the word workflow above.
Personally speaking, I’d use output to transmit the data and information / verbose to narrate actions (as it were), though that doesn’t translate to workflow very well. Is the purpose logging, along with the transmission?