Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9181347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:17:30+00:00 2026-06-17T18:17:30+00:00

Consider the script test.ps1: Get-EventLog -list | gm When it is called from the

  • 0

Consider the script “test.ps1:

Get-EventLog -list | gm

When it is called from the Powershell console (“.\test.ps1”), it outputs the members as expected.

However, the following scripts don’t show the output from “Get-EventLog -list | gm”:

Script 1

Get-EventLog -list | gm
break

Script 2

Get-EventLog -list | gm

$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", "Continua execucao"
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", "Cancela operacao"
$options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)
$result = $host.ui.PromptForChoice("Title", "Message", $options, 0) 

If I change “Get-EventLog -list | gm” to a text like “Hello World”, it is correctly displayed, in both cases.

Why is the output from the cmdlet not shown?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:17:31+00:00Added an answer on June 17, 2026 at 6:17 pm

    I took a look on some articles on powershell pipelining. The cmdlet used returns a collection of objects, and powershell’s default behavior is to forward the output to the screen.

    This article explains that the break statement will break the pipeline (in fact, it will break execution until it finds a parent loop), thus explaining the behavior of the first example.

    As for the second example, I assume powershell will only default to redirecting to the console on the end of the script execution. As the $host.ui.PromptForChoice does not use the first cmdlet call’s output, and produces it’s own, the results from Get-EventLog are just discarded.

    As it stands, always using “Out-Host”, as @Christian said, is the way to go.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following script: for host in $(get-all-hosts) do (restart-server $host; wait-for-server-to-come-up $host) &
Consider the script.. <html> <head> <script type=text/javascript> document.write('TEST'); </script> </head> <body> Some body content
When running a bash script on ubuntu 9.10, I get different behavior from bash
Consider this: <div class=test>one</div> <div class=test>two</div> <script> var i1 = $('.test'); var i2 =
Consider this simple example; <?php $text = test; ?> <script type=text/javascript defer=defer> var test;
Consider this simple msbuild script (xaml): <Activity xmlns=[....]> <Sequence> <mtbwa:WriteBuildMessage Message=Test message/> <mtbwa:WriteBuildWarning Message=Test
Consider ./my_script >/var/log/my_log Single echo statement from this script alone must to go to
I am running some shell test scripts from a python script under Windows. The
Consider the following code: <script> var i = 0; function test() { var _this
consider the following code: <script> function testFunc(){ alert('test') } $(function(){ var g = document.getElementById

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.