Darktux
Darktux

Reputation: 427

How can the argument to a batch file be intrun passed onto a powershell script?

i am trying to call a powershell script through bat file such as below;

Bat file name is Script .bat and its current cuntents are below;

Powershell -sta -Windowstyle Hidden Script.Ps1

I am passing an argument to the bat file how can i pass it on to the powershell script in the bat file?

Please do let me know if any questions or confirmations needed.

Upvotes: 0

Views: 170

Answers (1)

Bill_Stewart
Bill_Stewart

Reputation: 24525

In your shell script (batch file), you can write:

powershell -file script.ps1 %1

%1 will be replaced with the shell script's first command-line argument, which will be passed as the first argument to script.ps1.

Bill

Upvotes: 3

Related Questions