0

I have a Power Shell script that sits on a VM and creates a PSSession to a physical machine and runs a batch file. Running the batch file directly in the physical machine works as expected, however when I try running it remotely from the VM is it throwing up error.

Power Shell:

$Username = "Domain\User"
$Password = ConvertTo-SecureString "Password*" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ($Username, $password)
$session = New-PSSession -ComputerName "K2" -Credential $cred

Enter-PSSession -Session $session

Invoke-Command -ComputerName "K2" -ScriptBlock {
    Set-Location 'C:\Program Files\SmartBear\ReadyAPI-2.4.0\Go4Schools Tests\Test Runner'
    & '.\PSTR.bat'
}

Exit-PSSession
Get-PSSession | Remove-PSSession

Batch File:

"C:\Program Files\SmartBear\ReadyAPI-2.4.0\bin\testrunner.bat" -A -j "-fC:\Users\administrator.HYPERSPHERIC\Desktop\Go4Schools Tests\Test Results" "-RJUnit-Style HTML Report" -FXML -EDevTest "C:\Users\administrator.HYPERSPHERIC\Desktop\Go4Schools Tests\Project Saves\SoapUI_Mobile_API_Project.xml"

Error:

PS C:\> C:\Users\administrator.HYPERSPHERIC\Desktop\PS_TR.ps1

C:\Program Files\SmartBear\ReadyAPI-2.4.0\Go4Schools Tests\Test Runner>"C:\Program Files\SmartBear\ReadyAPI-2.4.0\bin\testrunner.bat" -A -j "-fC:\Program Files\SmartBear\ReadyAPI-2.4.0\Go4Sch
ools Tests\Test Results" "-RJUnit-Style HTML Report" -FXML -EDevTest "C:\Program Files\SmartBear\ReadyAPI-2.4.0\Go4Schools Tests\Project Saves\SoapUI_Mobile_API_Project.xml" 
Error: Could not find or load main class com.smartbear.ready.cmd.runner.pro.SoapUIProTestCaseRunner
    + CategoryInfo          : NotSpecified: (Error: Could no...oTestCaseRunner:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
    + PSComputerName        : K2
Ross
  • 2,463
  • 5
  • 35
  • 91

1 Answers1

0

Ready API and soapUI use some environment variables in testrunner.bat to set up dependencies and the like. So, whenever I've executed testrunner.bat with a script from outside of the application, I've always CD'ed to the bin directory first:

cd <Ready API installation directory>\bin 
./testrunner.bat ...
craigcaulfield
  • 3,381
  • 10
  • 32
  • 40
  • I have added the code that is in the batch file. and it is already pointing to the testrunner.bat file. or have I misunderstood? – Ross Jul 30 '18 at 07:07
  • PS isn't my first language, but it looks like you're giving the fully qualified path to `testrunner.bat`, which Ready API/soapUI doesn't always like. CD'ing to the `bin` directory and then running `testrunner.bat` from there fits better with the way the applications locate their own libraries. – craigcaulfield Jul 30 '18 at 07:55