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
sirichaiphumiratAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AntyraelICT SpecialistCommented:
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.
0
suriyaehnopCommented:
You can run using Windows Schedule tasks.

1. Create a batch file. Copy the below command and modify where you put your test-exchangeServerHealth.ps1 and save as .bat

powershell -command "&{C:\Temp\Monitoring\test-exchangeServerHealth.ps1}"

Open in new window


2. Create a windows schedule task to run the batch file every 2 hours
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SEHCCommented:
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
0
AntyraelICT SpecialistCommented:
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).
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.