0

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.

1 Answer 1

2

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.
Sign up to request clarification or add additional context in comments.

2 Comments

Option 1 depends on transfer method. If it's downloaded from web it will be "blocked" and will give the warning. If you go into the properties of the file and unblock it, it will work without warning. :-)
Use streams.exe from the Sysinterals suite to remove the ADS that contains Zone.Identifier data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.