0

I have created a ruby script to open Powershell and run a module I have created in it, the following command is what I am using to do this;

cmd /c C:\\NaviMedix\\Shared\\Bin\\psexec -s C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe C:\\HTTP\\loadServerManager.ps1

When running this locally in my own VM It works correctly and gives me the following output. Although when I store it in a cookbook as a library and run it through Run Deck it gives me a different output.

Local output:

PsExec v1.86 - Execute processes remotely
Copyright (C) 2001-2007 Mark Russinovich
Sysinternals - www.sysinternals.com

Starting C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe on SCSBCHEFTE


C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe exited on SCSBCHEFTEST04 with error code 0.

Welcome to Powershell augmented with NaviNet tools.


Directory: C:\Windows\system32\WindowsPowerShell\v1.0\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   2.0.0.0    AppLocker                           {Get-   AppLockerFile...
Manifest   2.0.0.0    Appx                                {Add-AppxPackage, ...
Manifest   1.0        BestPractices                       {Get-BpaModel, 

Success       : True
RestartNeeded : No
FeatureResult : {}
ExitCode      : NoChangeNeeded


Name                      : NET-HTTP-Activation
DisplayName               : HTTP Activation
Description               : HTTP Activation supports process activation via
                        HTTP. Applications that use HTTP Activation can
                        start and stop dynamically in response to work
                        items that arrive over the network via HTTP.
Installed                 : True
InstallState              : Installed

Run Deck output:

PsExec v1.86 - Execute processes remotely
Copyright (C) 2001-2007 Mark Russinovich
Sysinternals - www.sysinternals.com

Connecting to local system...
Starting PsExec service on local system...
Connecting with PsExec service on SCSBCHEFTEST01...
Starting C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe on SCSBCHEFTEST01...
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe exited on SCSBCHEFTEST01 with error code 1.

I want the local output to appear in Run Deck output but can not seem to make it work. Can anyone help me to solve this problem please?

  • `psexec` does odd things with output streams, this is quite a common scenario. Question is... Why are you using `cmd` to launch a `psexec` process that launches a `powershell` script? Why not directly launch powershell? – arco444 Feb 11 '15 at 10:25
  • I need to use Powershell 32 bit and if I try and directly open Powershell it will give me the 64 bit Powershell which I am unable to run my modules on. – Michael O'Reilly Feb 11 '15 at 10:43
  • Launch the 32bit version directly. Your current script calls the 64bit one anyway. 32bit is at: `C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe` – arco444 Feb 11 '15 at 10:48
  • Sorry I meant the other way about, I need to use Powershell 64 bit and if I try and directly open Powershell it will give me the 32 bit. Even when it is called directly it will still bring up the wrong Powershell :/ – Michael O'Reilly Feb 11 '15 at 11:03

0 Answers0