Avatar of sirichaiphumirat
sirichaiphumirat
Flag 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
PowershellExchangeWindows Server 2008

Avatar of undefined
Last Comment
Antyrael

8/22/2022 - Mon
Antyrael

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
suriyaehnop

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SEHC

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
Antyrael

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).
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes