Link to home
Start Free TrialLog in
Avatar of sirichaiphumirat
sirichaiphumiratFlag for United States of America

asked on

Automate powershell in exchange 2010

Is there a way to automate  a powershell command in exchange 2010.

I wanted to find a way to run a powershell command that does exchange health checks and wanted to run it every 2 hours.

this is the command test-exchangeServerHealth.ps1

is there a way to do that?

I was thinking to use the task scheduler, but to run this script the user the user will have to push R to run it.

link to the script

https://gallery.technet.microsoft.com/scriptcenter/Generate-Health-Report-for-19f5fe5f

thanks for your help
Avatar of Antyrael
Antyrael
Flag of Netherlands image

What you can do to bypass that security prompt is this.
In your Explorer, right-click the script and select Properties.
At the bottom, you will see a security message and an Unblock button.
Click that Unblock button and click Ok, from now on you can run the script without having to answer that security prompt and you can use Task Scheduler to run it automatically.
ASKER CERTIFIED SOLUTION
Avatar of suriyaehnop
suriyaehnop
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
As that script has an email option in it you can set up the batch file using the commands below and then add that to your task scheduler.



cd "C:\Scripts\"


powershell -command ./test-exchangeServerHealth.ps1 -Log -SendEmail
I thought the problem was having to push the R key, not making a batch file to run the script in (because that still requires pressing the R key).