0

I have .bat files that execute PowerShell scripts. They run fine from Task Scheduler or when running the batch files myself, but when I run them from Outlook (either from VBA script or using a Rule) - they just exit immediately without completing.

they look like this:

*PowerShell -file C:\Users\tenba1\Documents\Scripts\Account_Recon.ps1*

I also tried this:

*Call PowerShell -file C:\Users\tenba1\Documents\Scripts\Account_Recon.ps1*

Any idea why this happens?

user2725402
  • 4,349
  • 7
  • 24
  • 23
  • Sorry not sure what you mean. – user2725402 Sep 16 '13 at 15:04
  • 1
    UPDATE: Figured out that by default the execution policy of Powershell is set to Restricted, meaning you cannot run any scripts in batch mode. Changed the batch file to this and it worked: **Powershell.exe -ExecutionPolicy Bypass -File C:\Users\tenba1\Documents\Scripts\Account_Recon.ps1** – user2725402 Sep 16 '13 at 15:29

1 Answers1

0

You need to unrestrict your execution policy in the script call.

Powershell.exe -ExecutionPolicy Unrestricted -File filedir\filename.ps1
Lawivido
  • 146
  • 1
  • 1
  • 7