none
PSExec no output when a background job RRS feed

  • Question

  • Running PSExec within Powershell as a background job doesn’t produce all the output as a foreground job.

     

    PSExec v2.2 on Win10 Enterprise within PowerShell 5.1 run as administrator.

     

    Running PSExec to get ver of a computer as a foreground job works and produces expected output of:

    Microsoft Windows [Version 10.0.17134.254]

     

    Here is the command and output. Substituted actual computername for AComputerName in the posting.

     

    Invoke-Command -ScriptBlock { psexec -nobanner \\AComputerName cmd /c 'ver' }

     

    Microsoft Windows [Version 10.0.17134.254]

    psexec : Connecting to AComputerName...

    At line:1 char:31

    + ... nvoke-Command -ScriptBlock { psexec -nobanner \\AComputerName cmd /c 'ver' }

    +                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        + CategoryInfo          : NotSpecified: (Connecting to AComputerName...:String) [], RemoteException

        + FullyQualifiedErrorId : NativeCommandError

     

    Starting PSEXESVC service on AComputerName...Connecting with PsExec service on AComputerName...Starting cmd on AComputerName...

    cmd exited on AComputerName with error code 0.

     

     

    Now same psexec command except running as a background job. The Windows version is not in the output.

     

    $s = New-PSSession –ComputerName AComputerName

    Invoke-Command –Session $s –ScriptBlock { psexec –nobanner \\AComputerName cmd /c ‘ver’ } –AsJob

    $j = Get-Job

    $ r = $j | Get-Job

    cmd exited with error code 0.

        + CategoryInfo          : NotSpecified: (cmd exited with error code 0.:String) [], RemoteException

        + FullyQualifiedErrorId : NativeCommandError

        + PSComputerName        : AComputerName

    $r

     

     

     

     

    Invoke-Command -ScriptBlock { psexec -nobanner \\AComputerName cmd /c 'ver' }

     

    Microsoft Windows [Version 10.0.17134.254]

    psexec : Connecting to AComputerName...

    At line:1 char:31

    + ... nvoke-Command -ScriptBlock { psexec -nobanner \\AComputerName cmd /c 'ver' }

    +                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        + CategoryInfo          : NotSpecified: (Connecting to AComputerName...:String) [], RemoteException

        + FullyQualifiedErrorId : NativeCommandError

     

    Starting PSEXESVC service on AComputerName...Connecting with PsExec service on AComputerName...Starting cmd on AComputerName...

    cmd exited on AComputerName with error code 0.

     

     

    I’ve tried these technique with no success

    1. Using FQDN for AComputerName
    2. Redirection

     

    I’m using PSExec in a PS script to test whether a remote computer is configured to allow PSExec commands. There are instances where it is not.

     

    Tuesday, October 30, 2018 2:50 PM

All replies

  • I've been researching this in an attempt to learn extensive usage of psexec64; unfortunately, from the overall information I've gathered so far, I'm leaning towards the fairly probable assumption that a Windows Update has caused this issue. Whether the functionality is still possible through some type of workaround was the focus of my research at the time I ran across your post. 

    It might be worth noting, though, that one post in particular indicated the issue in their case was caused by conflicting 32 bit and 64 bit systems (though, I admittedly paid no attention to the timestamp for this post). Some community members suggested stopping the 64 bit service, deleting it, then attempting the action again, using psexec.exe. The thread was left unresolved, and the user concluded that Microsoft released an update (whether intentionally or not) that restricts access to 32 bit systems from 64 bit computers. 

    Personally, I am not experiencing this issue, but I'd be curious to know if copying the .exe files to SysWOW rather than System32 would have different results. At any rate, as a new user of this tool, I have been unable to produce any outcome other than the error code you've described in your post, save the 'shutdown' command. 

    I'll continue my search for a definitive resolution to this... but it's not looking good so far.

    Sunday, November 4, 2018 4:34 PM
  • I've been researching this in an attempt to learn extensive usage of psexec64; unfortunately, from the overall information I've gathered so far, I'm leaning towards the fairly probable assumption that a Windows Update has caused this issue. Whether the functionality is still possible through some type of workaround was the focus of my research at the time I ran across your post. 

    It might be worth noting, though, that one post in particular indicated the issue in their case was caused by conflicting 32 bit and 64 bit systems (though, I admittedly paid no attention to the timestamp for this post). Some community members suggested stopping the 64 bit service, deleting it, then attempting the action again, using psexec.exe. The thread was left unresolved, and the user concluded that Microsoft released an update (whether intentionally or not) that restricts access to 32 bit systems from 64 bit computers. 

    Personally, I am not experiencing this issue, but I'd be curious to know if copying the .exe files to SysWOW rather than System32 would have different results. At any rate, as a new user of this tool, I have been unable to produce any outcome other than the error code you've described in your post, save the 'shutdown' command. 

    I'll continue my search for a definitive resolution to this... but it's not looking good so far.


    I tried using pexec.exe and psexec64.exe explicitly with the issue still present.
    Thursday, November 8, 2018 2:42 PM