How to output objects to various coordinates of a powershell console window at the same time?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







1















I have been using powershell on a win 10 environment for a few months now, so still new to powershell and am trying use the powershell console as a technical point of display, whereby it cycles/loops through various components of data and displays the information at various coordinates of the console window. The problem I have is it can only display the data from any one particular loop at any one time. I suspect a type of multithreading is going to be needed like runspaces or psjobs, but I believe they are both background functions and cant display data in real-time, so not sure if the console even supports this kind of request.
Perhaps there is another way of going about this



I have tried putting all my scripts and get- command under one loop but it doesnt provide the "look" and feel we are trying to achieve. I want to be able to use the entire window as realestate for outputing objects. I have looked at psjobs and runspaces but they seem to work in the background.



So the code presented should output the get-service ojbects and the get-process objects to the coordinates specified at the same time.



function OBJ1{
[console]::setcursorposition(60,120)
Get-Process
]}
function OBJ2{
[console]::setcursorposition(10,70)
Get-Service
]}
Workflow obj3
{
Parallel
{
obj1
obj2
}
}
obj3


Instead the errors I get are:



<!-- language: lang-none -->
Microsoft.PowerShell.UtilityWrite-Error : Exception calling "SetCursorPosition" with "2" argument(s): "The handle is invalid.
"
At obj3:20 char:20
+
+ CategoryInfo : NotSpecified: (:) [Write-Error], RemoteException
+ FullyQualifiedErrorId : System.Management.Automation.RemoteException,Microsoft.PowerShell.Commands.WriteErrorCommand
+ PSComputerName : [localhost]

Microsoft.PowerShell.UtilityWrite-Error : Exception calling "SetCursorPosition" with "2" argument(s): "The handle is invalid.
"
At obj3:20 char:20
+
+ CategoryInfo : NotSpecified: (:) [Write-Error], RemoteException
+ FullyQualifiedErrorId : System.Management.Automation.RemoteException,Microsoft.PowerShell.Commands.WriteErrorCommand
+ PSComputerName : [localhost]









share|improve this question































    1















    I have been using powershell on a win 10 environment for a few months now, so still new to powershell and am trying use the powershell console as a technical point of display, whereby it cycles/loops through various components of data and displays the information at various coordinates of the console window. The problem I have is it can only display the data from any one particular loop at any one time. I suspect a type of multithreading is going to be needed like runspaces or psjobs, but I believe they are both background functions and cant display data in real-time, so not sure if the console even supports this kind of request.
    Perhaps there is another way of going about this



    I have tried putting all my scripts and get- command under one loop but it doesnt provide the "look" and feel we are trying to achieve. I want to be able to use the entire window as realestate for outputing objects. I have looked at psjobs and runspaces but they seem to work in the background.



    So the code presented should output the get-service ojbects and the get-process objects to the coordinates specified at the same time.



    function OBJ1{
    [console]::setcursorposition(60,120)
    Get-Process
    ]}
    function OBJ2{
    [console]::setcursorposition(10,70)
    Get-Service
    ]}
    Workflow obj3
    {
    Parallel
    {
    obj1
    obj2
    }
    }
    obj3


    Instead the errors I get are:



    <!-- language: lang-none -->
    Microsoft.PowerShell.UtilityWrite-Error : Exception calling "SetCursorPosition" with "2" argument(s): "The handle is invalid.
    "
    At obj3:20 char:20
    +
    + CategoryInfo : NotSpecified: (:) [Write-Error], RemoteException
    + FullyQualifiedErrorId : System.Management.Automation.RemoteException,Microsoft.PowerShell.Commands.WriteErrorCommand
    + PSComputerName : [localhost]

    Microsoft.PowerShell.UtilityWrite-Error : Exception calling "SetCursorPosition" with "2" argument(s): "The handle is invalid.
    "
    At obj3:20 char:20
    +
    + CategoryInfo : NotSpecified: (:) [Write-Error], RemoteException
    + FullyQualifiedErrorId : System.Management.Automation.RemoteException,Microsoft.PowerShell.Commands.WriteErrorCommand
    + PSComputerName : [localhost]









    share|improve this question



























      1












      1








      1








      I have been using powershell on a win 10 environment for a few months now, so still new to powershell and am trying use the powershell console as a technical point of display, whereby it cycles/loops through various components of data and displays the information at various coordinates of the console window. The problem I have is it can only display the data from any one particular loop at any one time. I suspect a type of multithreading is going to be needed like runspaces or psjobs, but I believe they are both background functions and cant display data in real-time, so not sure if the console even supports this kind of request.
      Perhaps there is another way of going about this



      I have tried putting all my scripts and get- command under one loop but it doesnt provide the "look" and feel we are trying to achieve. I want to be able to use the entire window as realestate for outputing objects. I have looked at psjobs and runspaces but they seem to work in the background.



      So the code presented should output the get-service ojbects and the get-process objects to the coordinates specified at the same time.



      function OBJ1{
      [console]::setcursorposition(60,120)
      Get-Process
      ]}
      function OBJ2{
      [console]::setcursorposition(10,70)
      Get-Service
      ]}
      Workflow obj3
      {
      Parallel
      {
      obj1
      obj2
      }
      }
      obj3


      Instead the errors I get are:



      <!-- language: lang-none -->
      Microsoft.PowerShell.UtilityWrite-Error : Exception calling "SetCursorPosition" with "2" argument(s): "The handle is invalid.
      "
      At obj3:20 char:20
      +
      + CategoryInfo : NotSpecified: (:) [Write-Error], RemoteException
      + FullyQualifiedErrorId : System.Management.Automation.RemoteException,Microsoft.PowerShell.Commands.WriteErrorCommand
      + PSComputerName : [localhost]

      Microsoft.PowerShell.UtilityWrite-Error : Exception calling "SetCursorPosition" with "2" argument(s): "The handle is invalid.
      "
      At obj3:20 char:20
      +
      + CategoryInfo : NotSpecified: (:) [Write-Error], RemoteException
      + FullyQualifiedErrorId : System.Management.Automation.RemoteException,Microsoft.PowerShell.Commands.WriteErrorCommand
      + PSComputerName : [localhost]









      share|improve this question
















      I have been using powershell on a win 10 environment for a few months now, so still new to powershell and am trying use the powershell console as a technical point of display, whereby it cycles/loops through various components of data and displays the information at various coordinates of the console window. The problem I have is it can only display the data from any one particular loop at any one time. I suspect a type of multithreading is going to be needed like runspaces or psjobs, but I believe they are both background functions and cant display data in real-time, so not sure if the console even supports this kind of request.
      Perhaps there is another way of going about this



      I have tried putting all my scripts and get- command under one loop but it doesnt provide the "look" and feel we are trying to achieve. I want to be able to use the entire window as realestate for outputing objects. I have looked at psjobs and runspaces but they seem to work in the background.



      So the code presented should output the get-service ojbects and the get-process objects to the coordinates specified at the same time.



      function OBJ1{
      [console]::setcursorposition(60,120)
      Get-Process
      ]}
      function OBJ2{
      [console]::setcursorposition(10,70)
      Get-Service
      ]}
      Workflow obj3
      {
      Parallel
      {
      obj1
      obj2
      }
      }
      obj3


      Instead the errors I get are:



      <!-- language: lang-none -->
      Microsoft.PowerShell.UtilityWrite-Error : Exception calling "SetCursorPosition" with "2" argument(s): "The handle is invalid.
      "
      At obj3:20 char:20
      +
      + CategoryInfo : NotSpecified: (:) [Write-Error], RemoteException
      + FullyQualifiedErrorId : System.Management.Automation.RemoteException,Microsoft.PowerShell.Commands.WriteErrorCommand
      + PSComputerName : [localhost]

      Microsoft.PowerShell.UtilityWrite-Error : Exception calling "SetCursorPosition" with "2" argument(s): "The handle is invalid.
      "
      At obj3:20 char:20
      +
      + CategoryInfo : NotSpecified: (:) [Write-Error], RemoteException
      + FullyQualifiedErrorId : System.Management.Automation.RemoteException,Microsoft.PowerShell.Commands.WriteErrorCommand
      + PSComputerName : [localhost]






      powershell-v4.0






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 3 at 6:24









      Triyugi Narayan Mani

      1,10951629




      1,10951629










      asked Jan 3 at 5:12









      alfialfi

      63




      63
























          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54016673%2fhow-to-output-objects-to-various-coordinates-of-a-powershell-console-window-at-t%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54016673%2fhow-to-output-objects-to-various-coordinates-of-a-powershell-console-window-at-t%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          MongoDB - Not Authorized To Execute Command

          in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

          How to fix TextFormField cause rebuild widget in Flutter