Automation

 View Only
  • 1.  Output from commandlets joining together out of sequence.

    Posted Jul 04, 2022 10:12 AM

     

    I am finding when I run this portion of PowerCLI:

     

    The output looks like this:

     

    So the output of the commandlet getting the ESXiShelIInteractiveTimeout value is being added into the table after the write-host commandlet that follows it. I have occasionally seen the output of all three commandlets joined together in the third table at the bottom. 

     

    Why does this happen and how do I prevent it?

     



  • 2.  RE: Output from commandlets joining together out of sequence.
    Best Answer

    Posted Jul 04, 2022 10:24 AM

    You are confusing the PS output engine by doing Select-Object with different properties.
    You can reset the output engine by doing a Out-Default after each Select-Object.



  • 3.  RE: Output from commandlets joining together out of sequence.

    Posted Jul 04, 2022 10:29 AM

    Super! LucD. That has helped. It sorted out some output from further down the code as well.

    Why does the PS output engine get confused? 



  • 4.  RE: Output from commandlets joining together out of sequence.

    Posted Jul 04, 2022 10:33 AM

    It uses the 1st Select-Object and assumes that all your following Select-Object cmdlets will have the same number of properties.
    And it combines those 2 together, as you noticed.
    With Out-Default you ask in fact for a reset, and the output engine forgets everything it has "seen" before.



  • 5.  RE: Output from commandlets joining together out of sequence.

    Posted Jul 04, 2022 10:37 AM

    OK, that sounds like a deliberate design feature and quite useful. I don't know why I haven't discovered this before.

    Thanks for the help.