Workflow Engine Looking for PowerShell in Simpana\Base Directory?

Last post 09-11-2014, 8:42 PM by PeteC. 7 replies.
Sort Posts: Previous Next
  • Workflow Engine Looking for PowerShell in Simpana\Base Directory?
    Posted: 09-11-2014, 1:21 AM

    Hi all, so I'm finally trying to call a PowerShell script from the Workflow engine and I've immediately hit a big stumbling block that Google and documentation can't seem to help with.

    Using the "ExecuteScript" utility, I point the "StartUpPath" to the directory containing my script and select "PowerShell" as the "scriptType".

    In additiion, I provide the full path to my "script" variable and provide the arguments I need to pass.

    When I deploy and execute the Workflow, it goes to a Pending state and the CVD.log on the Workflow engine server reports the following:

    2116 718 09/11 14:47:25 ### [CVD ] ** CVD_CVSESSION_ERROR: RemoteHost=backupwc1.lab.melbourneit.com: Remote execution failed.
    * Received remote execute request for process powershell.
    * Could not find this executable: C:\Program Files\CommVault\Simpana\Base\powershell.exe.
    2116 718 09/11 14:47:25 ### [CVD ] [cvsHandleRemoteExecRequest] RemoteHost=backupwc1.lab.melbourneit.com Command=powershell. Validating executable is not succeeded. Error Msg:[ Executable file not found. ]
    2116 718 09/11 14:47:25 ### [CVD ] [cvsHandleRemoteExecRequest] CVD_CVSESSION_INFO: RemoteHost=backupwc1.lab.melbourneit.com. Received remote exec request [cmd='powershell'].
    Why would the Workflow engine be looking in the Simpana Base directory for PowerShell?
    So far I haven't found any options to define the location of PowerShell and it is in the default location that I don't think can be changed anyway:
    C:\Windows\System32\WindowsPowerShell\v1.0
  • Re: Workflow Engine Looking for PowerShell in Simpana\Base Directory?
    Posted: 09-11-2014, 8:20 AM

    Peter C,

    I will check into this for you.  In the meantime (so im clear), are you embedding the script into the Script Parameter field of the workflow activity?  Or is the script sitting locally on the client machine, and you are calling it via the command with the arguments included?

    If you are not embedding the script into the workflow, I would try that because that is really how this activity is intended to be used.

  • Re: Workflow Engine Looking for PowerShell in Simpana\Base Directory?
    Posted: 09-11-2014, 8:36 AM

    Can  you validate that the path to powershell.exe ( %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\) is in the system path statement on the client (backupwc1) you are trying to execute the script on?

  • Re: Workflow Engine Looking for PowerShell in Simpana\Base Directory?
    Posted: 09-11-2014, 6:07 PM

    dmcvault:

    Peter C,

    I will check into this for you.  In the meantime (so im clear), are you embedding the script into the Script Parameter field of the workflow activity?  Or is the script sitting locally on the client machine, and you are calling it via the command with the arguments included?

    If you are not embedding the script into the workflow, I would try that because that is really how this activity is intended to be used.

    Thanks David, the script is located locally on the client rather than being embedded in the Workflow.

    I just reread Books Online and yes I completely missed the fact it indicates the script should be embedded and it is then run on the client.

    I'll fix that and let you know how I go.

    It actually calls the VMware PowerCLI snap in but I can't see that being an issue as the snap in is installed.

    Incidentally the client "backupwc1" is my Workflow engine server as I have it separate to the CommServe.

  • Re: Workflow Engine Looking for PowerShell in Simpana\Base Directory?
    Posted: 09-11-2014, 6:08 PM

    cwsunderland:

    Can  you validate that the path to powershell.exe ( %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\) is in the system path statement on the client (backupwc1) you are trying to execute the script on?

    Yep, I can definitely verify it is in the path statement.

  • Re: Workflow Engine Looking for PowerShell in Simpana\Base Directory?
    Posted: 09-11-2014, 6:18 PM

    Ok, no joy with the script embedded in the workflow now unfortunately, exactly the same error.

    I can see in WorkflowEngine.log where it is displaying my script but CVD.log still reports it can't find powershell.exe in the Simpana Base directory.

    The password being pasted below is a dummy so don't be concerned about that Smile

     

    1128 1   09/12 08:11:06 112551 WorkflowManager         : initializing job [112551] for workflow [MIT - Data Recovery Alert Power On MA]
    1128 1034 09/12 08:11:06 112551 WorkflowManager : starting workflow [MIT - Data Recovery Alert Power On MA] with inputs [<inputs />]
    1128 1054 09/12 08:11:07 112551 SetActivityInputs : starting activity [Start (Start_1)] with inputs [<inputs />]
    1128 1054 09/12 08:11:07 112551 WorkflowStep : completing activity [Start (Start_1)] with status [COMPLETED], outputs [<Start_1><system><startTime>1410473466</startTime><status>RUNNING</status><timedOut>false</timedOut></system></Start_1>]
    1128 1078 09/12 08:11:07 112551 SetActivityInputs : starting activity [Check VM Power State (ExecuteScript_1)] with inputs [<inputs><client><clientName>backupwc1</clientName><clientId>126</clientId></client><startUpPath>C:\Windows\System32\WindowsPowerShell\v1.0</startUpPath><scriptType>PowerShell</scriptType><script>&lt;#=========================================================================================================&#xD;
    GetVMPowerState.ps1&#xD;
    ---------------------------------------------------------------------------------&#xD;
    This script will get the power state for the provided VM.&#xD;
    ---------------------------------------------------------------------------------&#xD;
    Version Control:&#xD;
    20140911.01 - Initial script creation.&#xD;
    =========================================================================================================#&gt;&#xD;
    &#xD;
    &lt;#---------------------------------------------------------------------------------&#xD;
    Get command line parameters.&#xD;
    ---------------------------------------------------------------------------------#&gt;&#xD;
    Param (&#xD;
    [Parameter(Mandatory=$true)][string]$vCenter,&#xD;
    [Parameter(Mandatory=$true)][string]$VMName,&#xD;
    [Parameter(Mandatory=$true)][string]$Username,&#xD;
    [Parameter(Mandatory=$true)][string]$Password&#xD;
    )&#xD;
    &#xD;
    &lt;#---------------------------------------------------------------------------------&#xD;
    Load the PowerCLI snapin.&#xD;
    ---------------------------------------------------------------------------------#&gt;&#xD;
    Add-PSSnapin VMware.VimAutomation.Core&#xD;
    &#xD;
    &lt;#---------------------------------------------------------------------------------&#xD;
    Set debug on (1) or off (0).&#xD;
    ---------------------------------------------------------------------------------#&gt;&#xD;
    $debug = 1</script><arguments>-vCenter "vmm01.lab.melbourneit.com" -VMName "linuxma3.lab" -Username "LAB\maint_CVWF" -Password "test1234"</arguments><waitForProcessCompletion>true</waitForProcessCompletion></inputs>]
    1128 1078 09/12 08:11:07 112551 CommandActivity : executing script type [PowerShell] with arguments [-vCenter "vmm01.lab.melbourneit.com" -VMName "linuxma3.lab" -Username "LAB\maint_CVWF" -Password "test1234"] on host [backupwc1] as user []
    1128 1078 09/12 08:11:07 112551 CommandActivity : SEVERE: error executing command [] on host [backupwc1], errorCode [1], exitCode [0], error []
    1128 1078 09/12 08:11:07 112551 ExecuteActivity : WARNING: execution of activity [Check VM Power State (ExecuteScript_1)] returned a status of [FAILED]
    1128 1078 09/12 08:11:07 112551 JobManager : completing attempt for activity [Check VM Power State (ExecuteScript_1)] with status [FAILED]
    1128 1034 09/12 08:11:07 112551 WorkflowManager : workflow [MIT - Data Recovery Alert Power On MA] exiting with status [PENDING]
    2116  718   09/12 08:11:07 ### [CVD        ]   ** CVD_CVSESSION_ERROR: RemoteHost=backupwc1.lab.melbourneit.com: Remote execution failed.
    * Received remote execute request for process powershell.
    * Could not find this executable: C:\Program Files\CommVault\Simpana\Base\powershell.exe.
    2116 718 09/12 08:11:07 ### [CVD ] [cvsHandleRemoteExecRequest] RemoteHost=backupwc1.lab.melbourneit.com Command=powershell. Validating executable is not succeeded. Error Msg:[ Executable file not found. ]
    2116 718 09/12 08:11:07 ### [CVD ] [cvsHandleRemoteExecRequest] CVD_CVSESSION_INFO: RemoteHost=backupwc1.lab.melbourneit.com. Received remote exec request [cmd='powershell'].
  • Re: Workflow Engine Looking for PowerShell in Simpana\Base Directory?
    Posted: 09-11-2014, 7:32 PM

    Ok so if I set it to impersonate a user, it runs PowerShell successfully and I've had many issues running scripts as local system accounts so this makes sense.

    Now however I cannot seem to successfully pass parameters to my script.

    I have my param section defined and need to pass parameters via these variables, but this errors out every time. I'm assuming there's a better/right way to do this?

    In my script:

    Param (
    [Parameter(Mandatory=$true)][string]$vCenter,
    [Parameter(Mandatory=$true)][string]$VMName,
    [Parameter(Mandatory=$true)][string]$Username,
    [Parameter(Mandatory=$true)][string]$Password
    )
    And the "arguments" variable:
    -vCenter "vmm01.lab.melbourneit.com" -VMName "linuxma3.lab" -Username "LAB\maint_CVWF" -Password "test1234"
    Again, the password is a dummy :)
  • Re: Workflow Engine Looking for PowerShell in Simpana\Base Directory?
    Posted: 09-11-2014, 8:42 PM

    And just because I like to constantly post updates to myself... Laughing

    It seems I simply need to re-think how I use PowerShell in this instance...

    I think I get it now!

    Embedding the script in the Workflow means it is "compiled" only when the Workflow runs, meaning I don't need to pass command line parameters to the PowerShell script at all.

    Instead, I define variables in the workflow and I can therefore reference these Workflow variables directly in the PowerShell script itself. Nice and simple once you get it!

    So I now have this functioning and can get the power state of my MediaAgent and can start expanding this Workflow to do what I need.

    <#=========================================================================================================
    GetVMPowerState.ps1
    ---------------------------------------------------------------------------------
    This script will get the power state for the provided VM.
    ---------------------------------------------------------------------------------
    Version Control:
    20140911.01 - Initial script creation.
    =========================================================================================================#>

    <#---------------------------------------------------------------------------------
    Get script parameters.
    ---------------------------------------------------------------------------------#>
    $vCenter = "xpath:{/workflow/variables/vCenter}"
    $VCUsername = "xpath:{/workflow/variables/VCUsername}"
    $VCPassword = "xpath:{/workflow/variables/VCPassword}"
    $VMName = "xpath:{/workflow/inputs/MediaAgent/mediaAgentName}"

    <#---------------------------------------------------------------------------------
    Load the PowerCLI snapin.
    ---------------------------------------------------------------------------------#>
    Add-PSSnapin VMware.VimAutomation.Core

    <#---------------------------------------------------------------------------------
    Set debug on (1) or off (0).
    ---------------------------------------------------------------------------------#>
    $debug = 1

    $VCConnected = Connect-VIServer -Server $vCenter
    If ($VCConnected.IsConnected) {
    If ($VM = Get-VM -Name $VMName) {
    $PowerState = $VM.PowerState
    If ($PowerState -eq "PoweredOn") {
    Write-Output "$VMName is powered on"
    Exit 0
    } Else {
    Write-Output "$VMName is in state $PowerState"
    Exit 1
    }
    } Else {
    Write-Output "$VMname not found"
    Exit 2
    }
    } Else {
    Write-Output "Not connected to $vCenter"
    Exit 3
    }
  • The content of the forums, threads and posts reflects the thoughts and opinions of each author, and does not represent the thoughts, opinions, plans or strategies of Commvault Systems, Inc. ("Commvault") and Commvault undertakes no obligation to update, correct or modify any statements made in this forum. Any and all third party links, statements, comments, or feedback posted to, or otherwise provided by this forum, thread or post are not affiliated with, nor endorsed by, Commvault.
    Commvault, Commvault and logo, the “CV” logo, Commvault Systems, Solving Forward, SIM, Singular Information Management, Simpana, Commvault Galaxy, Unified Data Management, QiNetix, Quick Recovery, QR, CommNet, GridStor, Vault Tracker, InnerVault, QuickSnap, QSnap, Recovery Director, CommServe, CommCell, SnapProtect, ROMS, and CommValue, are trademarks or registered trademarks of Commvault Systems, Inc. All other third party brands, products, service names, trademarks, or registered service marks are the property of and used to identify the products or services of their respective owners. All specifications are subject to change without notice.
    Close
    Copyright © 2019 Commvault | All Rights Reserved. | Legal | Privacy Policy