Shree
Shree

Reputation: 233

Run a remote powershell script from a batch file

I want to have my batch file run a remote powerhell script.

I have Powershell \ip\Myscript.ps1

But it asks me for do i want to run this remote script. I want to bypass this. with a -confirm:$false

How can i use that in a batch.

Upvotes: 0

Views: 695

Answers (1)

vonPryz
vonPryz

Reputation: 24071

You got a few options here.

  1. Copy the .ps1 file to a local directory and then call it via Powershell. An ugly hack, but sometimes necessary if Execution Policy must not be changed.
  2. Sign the .ps1 file. A huge pain in the backside.
  3. Tell Powershell not to worry about Execytion Policy. The easy and dangerous way: powershell -executionpolicy unrestricted \\server\share\someScript.ps1.

Upvotes: 2

Related Questions