sirichaiphumirat
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
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.
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
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
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-exchangeServerHealt h.ps1 -Log -SendEmail
cd "C:\Scripts\"
powershell -command ./test-exchangeServerHealt
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).
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.