Forum Discussion

nileshdhone's avatar
nileshdhone
New Contributor
2 months ago

Running Power shell script through Test Execute is not working.

I have executed the power shell script(for generating the logs)through Test Complete and its working fine. We are able to see the logs generated.

The same power shell script while executing through Test Execute, its not working.

Is there any setting I need to do in Test Execute before execution of Power shell script.?

3 Replies

  • rraghvani's avatar
    rraghvani
    Icon for Champion Level 3 rankChampion Level 3

    How are you executing the PowerShell scripts? What do the PowerShell scripts do? Are you running TestExecute on the same machine?

  • scot1967's avatar
    scot1967
    Icon for Champion Level 1 rankChampion Level 1

    The first thing that comes to mind is TestExecute will need permission to run power shell scripts.  I know we need to set TestComplete to 'Run as administrator'.  Could it be a permission issue?  Just a guess.  But, no there isn't anything as far as TestExecute goes that I am aware of.  Let us know what sort of errors you see or what the failure is and we can help more.  

    ... If you find my posts helpful drop me a like! 👍 Be sure to mark the best answer if you get one to help others out and to credit the one who helped you.  😎

  • JDR2500's avatar
    JDR2500
    Frequent Contributor

    Try running it with your same command line arguments from a Command Prompt, not PS.  You may get more information back on the problem.  Include "-NoExit " as the first argument.  That will leave the PS window open and might reveal what's going wrong.

    This is the method I've used from TC with VBScript.  Getting the right number of quotation marks around the parameters has always been the biggest challenge for me.

    Set oShell = Sys.OleObject("WScript.Shell") 
    s_Columns = """" & s_Columns & """"
          s_PSScriptPath = s_path & "Utility Files\CompareExcelSpecifiedCols.ps1"
          s_PowershellInput = "powershell.exe -ExecutionPolicy Bypass -File " _
            & """" & s_PSScriptPath & """" & " -File1 " & s_ResourceFileName _
            & " -File2 " & s_TestFileName & " -OutputFile " & s_OutputFile _
            & " -SheetName " & """" & s_SheetName & """" & " -ColumnsToCompare " & s_Columns
    
      Set oExec = oShell.Exec(s_PowershellInput)