TestQA1
9 months agoFrequent Contributor
How to pass parameters in WshShell.Run
Hi all,
I hope you all are doing well.
I use powershell files alot in Javascript test complete scripts.
But I am struggling to pass paramaters in string.
var testingP = "some path";
var source = "some path";
var destination= "des path";
WshShell.Run("powershell -file \"" + testingP + "ABCD.ps1\"" & source & destination);
The powerhsell file executes if I dont add & source & destination but I need to pass parameters.
My PS file:
[CmdletBinding()]
param (
$source,
$destination
)
function copy($source, $destination) {
Copy-Item –Path $source -Destination $destination -Recurse
}
thanks
Use Log.Message() so that you can see what the output is going to be like. For example,
Also, ensure you know the difference between + and & within a string.