Run powershell through winexe/psexec












4














I'm trying to connect to a Windows 2012 server from Ubuntu.



winexe --user <USER> --password <SERVER> //SERVER cmd.exe 


works just fine.



However,



winexe --user <USER> --password <SERVER> //SERVER powershell.exe`


just hangs.



It displays:



Windows PowerShell
Copyright (C) 2012 Microsoft Corporation. All rights reserved.


but after that it just hangs and won't respond to keypresses.



Is there a parameter I need to pass to powershell to get it to run in interactive mode or anything?



EDIT



If I run the above command through strace, it seems to be waiting for the server to send something back.



epoll_wait(4, {}, 1, 10)                = 0
epoll_wait(4, {}, 1, 10) = 0
epoll_wait(4, {}, 1, 10) = 0









share|improve this question
























  • Did you try --interactive=1 and --system? Managing Windows Powershell from Linux terminal
    – phuclv
    Nov 19 '16 at 5:07
















4














I'm trying to connect to a Windows 2012 server from Ubuntu.



winexe --user <USER> --password <SERVER> //SERVER cmd.exe 


works just fine.



However,



winexe --user <USER> --password <SERVER> //SERVER powershell.exe`


just hangs.



It displays:



Windows PowerShell
Copyright (C) 2012 Microsoft Corporation. All rights reserved.


but after that it just hangs and won't respond to keypresses.



Is there a parameter I need to pass to powershell to get it to run in interactive mode or anything?



EDIT



If I run the above command through strace, it seems to be waiting for the server to send something back.



epoll_wait(4, {}, 1, 10)                = 0
epoll_wait(4, {}, 1, 10) = 0
epoll_wait(4, {}, 1, 10) = 0









share|improve this question
























  • Did you try --interactive=1 and --system? Managing Windows Powershell from Linux terminal
    – phuclv
    Nov 19 '16 at 5:07














4












4








4


1





I'm trying to connect to a Windows 2012 server from Ubuntu.



winexe --user <USER> --password <SERVER> //SERVER cmd.exe 


works just fine.



However,



winexe --user <USER> --password <SERVER> //SERVER powershell.exe`


just hangs.



It displays:



Windows PowerShell
Copyright (C) 2012 Microsoft Corporation. All rights reserved.


but after that it just hangs and won't respond to keypresses.



Is there a parameter I need to pass to powershell to get it to run in interactive mode or anything?



EDIT



If I run the above command through strace, it seems to be waiting for the server to send something back.



epoll_wait(4, {}, 1, 10)                = 0
epoll_wait(4, {}, 1, 10) = 0
epoll_wait(4, {}, 1, 10) = 0









share|improve this question















I'm trying to connect to a Windows 2012 server from Ubuntu.



winexe --user <USER> --password <SERVER> //SERVER cmd.exe 


works just fine.



However,



winexe --user <USER> --password <SERVER> //SERVER powershell.exe`


just hangs.



It displays:



Windows PowerShell
Copyright (C) 2012 Microsoft Corporation. All rights reserved.


but after that it just hangs and won't respond to keypresses.



Is there a parameter I need to pass to powershell to get it to run in interactive mode or anything?



EDIT



If I run the above command through strace, it seems to be waiting for the server to send something back.



epoll_wait(4, {}, 1, 10)                = 0
epoll_wait(4, {}, 1, 10) = 0
epoll_wait(4, {}, 1, 10) = 0






ubuntu powershell windows-server-2012 psexec






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 21 '13 at 18:02

























asked Jun 20 '13 at 3:31









javanix

2341821




2341821












  • Did you try --interactive=1 and --system? Managing Windows Powershell from Linux terminal
    – phuclv
    Nov 19 '16 at 5:07


















  • Did you try --interactive=1 and --system? Managing Windows Powershell from Linux terminal
    – phuclv
    Nov 19 '16 at 5:07
















Did you try --interactive=1 and --system? Managing Windows Powershell from Linux terminal
– phuclv
Nov 19 '16 at 5:07




Did you try --interactive=1 and --system? Managing Windows Powershell from Linux terminal
– phuclv
Nov 19 '16 at 5:07










4 Answers
4






active

oldest

votes


















0














Try




winexe --interactive=1 --user<USER> --password <SERVER> //SERVER powershell.exe







share|improve this answer























  • That doesn't seem to make any difference.
    – javanix
    Jun 21 '13 at 17:58



















0














The easiest way is to run the command directly using single quote. For example listing the processes can be done as follows:



winexe -U "DomainPC-Name" //IP Address 'powershell.exe Get-Process'





share|improve this answer































    0














    Powershell seems a "Windows Gui Program", which tries to interact with the desktop. Obviously this is not possible, if connected from remote (maybe in Windows XP). To be interactive and connect the input of the powershell to stdin use "-Command -".



    Which lets the powershell interact with stdin. You can type commands and see the output, but you do not get the prompt from powershell.






    share|improve this answer

















    • 1




      no, powershell is a console tool. It can be called from cmd just like bash
      – phuclv
      Nov 19 '16 at 5:08



















    0














    Winexe sounds quite outdated and does not state supporting Windows Server 2008 and newer versions of Windows.



    PowerShell went open source, you can download Ubuntu 14.04 and 16.04 .deb packages from GitHub:
    https://github.com/PowerShell/PowerShell



    After installing it you can remotely connect to the Windows Server 2012 machine with the Enter-PSSession PowerShell cmdlet.






    share|improve this answer























      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "3"
      };
      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%2fsuperuser.com%2fquestions%2f609835%2frun-powershell-through-winexe-psexec%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      Try




      winexe --interactive=1 --user<USER> --password <SERVER> //SERVER powershell.exe







      share|improve this answer























      • That doesn't seem to make any difference.
        – javanix
        Jun 21 '13 at 17:58
















      0














      Try




      winexe --interactive=1 --user<USER> --password <SERVER> //SERVER powershell.exe







      share|improve this answer























      • That doesn't seem to make any difference.
        – javanix
        Jun 21 '13 at 17:58














      0












      0








      0






      Try




      winexe --interactive=1 --user<USER> --password <SERVER> //SERVER powershell.exe







      share|improve this answer














      Try




      winexe --interactive=1 --user<USER> --password <SERVER> //SERVER powershell.exe








      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Jun 20 '13 at 16:59









      Der Hochstapler

      67.3k49230284




      67.3k49230284










      answered Jun 20 '13 at 15:01









      user2480011

      465




      465












      • That doesn't seem to make any difference.
        – javanix
        Jun 21 '13 at 17:58


















      • That doesn't seem to make any difference.
        – javanix
        Jun 21 '13 at 17:58
















      That doesn't seem to make any difference.
      – javanix
      Jun 21 '13 at 17:58




      That doesn't seem to make any difference.
      – javanix
      Jun 21 '13 at 17:58













      0














      The easiest way is to run the command directly using single quote. For example listing the processes can be done as follows:



      winexe -U "DomainPC-Name" //IP Address 'powershell.exe Get-Process'





      share|improve this answer




























        0














        The easiest way is to run the command directly using single quote. For example listing the processes can be done as follows:



        winexe -U "DomainPC-Name" //IP Address 'powershell.exe Get-Process'





        share|improve this answer


























          0












          0








          0






          The easiest way is to run the command directly using single quote. For example listing the processes can be done as follows:



          winexe -U "DomainPC-Name" //IP Address 'powershell.exe Get-Process'





          share|improve this answer














          The easiest way is to run the command directly using single quote. For example listing the processes can be done as follows:



          winexe -U "DomainPC-Name" //IP Address 'powershell.exe Get-Process'






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 16 '13 at 19:49









          Kevin Panko

          5,849113648




          5,849113648










          answered Dec 16 '13 at 19:31









          VAM

          1




          1























              0














              Powershell seems a "Windows Gui Program", which tries to interact with the desktop. Obviously this is not possible, if connected from remote (maybe in Windows XP). To be interactive and connect the input of the powershell to stdin use "-Command -".



              Which lets the powershell interact with stdin. You can type commands and see the output, but you do not get the prompt from powershell.






              share|improve this answer

















              • 1




                no, powershell is a console tool. It can be called from cmd just like bash
                – phuclv
                Nov 19 '16 at 5:08
















              0














              Powershell seems a "Windows Gui Program", which tries to interact with the desktop. Obviously this is not possible, if connected from remote (maybe in Windows XP). To be interactive and connect the input of the powershell to stdin use "-Command -".



              Which lets the powershell interact with stdin. You can type commands and see the output, but you do not get the prompt from powershell.






              share|improve this answer

















              • 1




                no, powershell is a console tool. It can be called from cmd just like bash
                – phuclv
                Nov 19 '16 at 5:08














              0












              0








              0






              Powershell seems a "Windows Gui Program", which tries to interact with the desktop. Obviously this is not possible, if connected from remote (maybe in Windows XP). To be interactive and connect the input of the powershell to stdin use "-Command -".



              Which lets the powershell interact with stdin. You can type commands and see the output, but you do not get the prompt from powershell.






              share|improve this answer












              Powershell seems a "Windows Gui Program", which tries to interact with the desktop. Obviously this is not possible, if connected from remote (maybe in Windows XP). To be interactive and connect the input of the powershell to stdin use "-Command -".



              Which lets the powershell interact with stdin. You can type commands and see the output, but you do not get the prompt from powershell.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Dec 26 '13 at 12:07









              Marco

              594




              594








              • 1




                no, powershell is a console tool. It can be called from cmd just like bash
                – phuclv
                Nov 19 '16 at 5:08














              • 1




                no, powershell is a console tool. It can be called from cmd just like bash
                – phuclv
                Nov 19 '16 at 5:08








              1




              1




              no, powershell is a console tool. It can be called from cmd just like bash
              – phuclv
              Nov 19 '16 at 5:08




              no, powershell is a console tool. It can be called from cmd just like bash
              – phuclv
              Nov 19 '16 at 5:08











              0














              Winexe sounds quite outdated and does not state supporting Windows Server 2008 and newer versions of Windows.



              PowerShell went open source, you can download Ubuntu 14.04 and 16.04 .deb packages from GitHub:
              https://github.com/PowerShell/PowerShell



              After installing it you can remotely connect to the Windows Server 2012 machine with the Enter-PSSession PowerShell cmdlet.






              share|improve this answer




























                0














                Winexe sounds quite outdated and does not state supporting Windows Server 2008 and newer versions of Windows.



                PowerShell went open source, you can download Ubuntu 14.04 and 16.04 .deb packages from GitHub:
                https://github.com/PowerShell/PowerShell



                After installing it you can remotely connect to the Windows Server 2012 machine with the Enter-PSSession PowerShell cmdlet.






                share|improve this answer


























                  0












                  0








                  0






                  Winexe sounds quite outdated and does not state supporting Windows Server 2008 and newer versions of Windows.



                  PowerShell went open source, you can download Ubuntu 14.04 and 16.04 .deb packages from GitHub:
                  https://github.com/PowerShell/PowerShell



                  After installing it you can remotely connect to the Windows Server 2012 machine with the Enter-PSSession PowerShell cmdlet.






                  share|improve this answer














                  Winexe sounds quite outdated and does not state supporting Windows Server 2008 and newer versions of Windows.



                  PowerShell went open source, you can download Ubuntu 14.04 and 16.04 .deb packages from GitHub:
                  https://github.com/PowerShell/PowerShell



                  After installing it you can remotely connect to the Windows Server 2012 machine with the Enter-PSSession PowerShell cmdlet.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Mar 27 '17 at 11:35

























                  answered Mar 27 '17 at 11:30









                  Christophe

                  1,1901027




                  1,1901027






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Super User!


                      • 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.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • 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%2fsuperuser.com%2fquestions%2f609835%2frun-powershell-through-winexe-psexec%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

                      QoS: MAC-Priority for clients behind a repeater

                      Ивакино (Тотемский район)

                      Can't locate Autom4te/ChannelDefs.pm in @INC (when it definitely is there)