Deepak Rohilla
Deepak Rohilla

Reputation: 95

Unable to call script with parameter and scriptfile

I'm unable to call powershell with start-process when i'm passing both scriptfile and parameters

start-process powershell d:\startTask.ps1 "param1" "param2" "param3"

My startTask.ps1 looks like below

param([string]$x="default",[string]$y="default",[string]$z="default")
echo "x: $x"
echo "y: $y"
echo "z: $z"

Upvotes: 0

Views: 109

Answers (2)

Jackie
Jackie

Reputation: 2634

& powershell d:\startTask.ps1 "param1" "param2" "param3"

Upvotes: 1

CB.
CB.

Reputation: 60938

try:

Start-Process Powershell -ArgumentList "-noexit","-File d:\startTask.ps1 param1 param2 param3"

Upvotes: 2

Related Questions