Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 7 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
I'm using PowerShell Studio to build an EXE of a large PS1 that needs a clean but basic user interface on the console. I find that when the generated EXE runs there are cmdlets that generate undesirable informative messages. These don't show up when running in PowerShell. I can't seem to find a way to eliminate them (e.g., preferences).
The best practice is to pipe the selected output to Out-Null or assign it to the $null variable.
... | Out-Null
$null = ...
But, I bet you can be more selective. If these are truly informational messages, i.e. in the Information stream, you can use the InformationAction common parameter to suppress them. For info, see https://blogs.technet.microsoft.com/hey ... on-stream/
To tell which stream the messages are coming from, try to save them in a variable or, as @OldLost suggests, redirect them. In the meantime, I'll try to spin up a script that tells which stream a message is coming from.
-- juneb
June Blender
Technology Evangelist
SAPIEN Technologies, Inc.
Thanks for your suggestions. I think piping the output and Out-Null were both things that I had tried without success (i.e., the messages still went to the console), but I'll give them a try and let you know.
Thanks
EDIT: Just tried both piping and Out-Null. No help in the EXE. The unwanted output still appears.
The messages you are getting are not normal for the commands. I suspect there may be a configuration error. I have used those commands many times and have never seen spurious output.
For info: Assigning the command to avraiable performs the same function as [I[ing to Ou-Null.
I use this because it is more explicit and easier to see in a script:
When you say some EXE outputs can't be suppressed, do you mean that console output from some cmdlets can't be suppressed in a generated EXE?
When you say a configuration error, can you please be more specific? The output doesn't show in PowerShell or PowerShell ISE, so is it some kind of configuration error in building the EXE? It really is 100% defaults. Really, the code above will demonstrate the error when built into an EXE with the default settings.
Thanks for your ideas. It's seems really odd that it's impossible to suppress these, but only when running as an EXE.
I am going to vote on a bug/feature in the Sapien Host. I bet running this under the VS debugger will find the issue. I suspect there is some odd API debug code laying around in the API that is called by these CmdLets.
bottom line it cannot be a bug in the script as written.
When you say some EXE outputs can't be suppressed, do you mean that console output from some cmdlets can't be suppressed in a generated EXE?
When you say a configuration error, can you please be more specific? The output doesn't show in PowerShell or PowerShell ISE, so is it some kind of configuration error in building the EXE? It really is 100% defaults. Really, the code above will demonstrate the error when built into an EXE with the default settings.
Thanks for your ideas. It's seems really odd that it's impossible to suppress these, but only when running as an EXE.
This topic is 7 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.