Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Health Checker how to setup schedule task doc #1008

Closed
techieweenie opened this issue May 9, 2022 · 15 comments · Fixed by #1109
Closed

Health Checker how to setup schedule task doc #1008

techieweenie opened this issue May 9, 2022 · 15 comments · Fixed by #1109
Assignees
Labels
Awaiting feedback Waiting for feedback. Health Checker question Further information is requested Work Item Work Item for project work

Comments

@techieweenie
Copy link

Provide Version Number
Provide the version of the script that has the issue.
Version 22.04.26.1650

Describe the issue
A clear and concise description of the issue.
Script works great when run manually. However, I am tasked with running it as a scheduled task monthly. I have tried setting up as a scheduled task on the Exchange Server with these parameters in the action tab:
Start a program:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
argument:
-NonInteractive -WindowStyle Hidden -command ".'C:\Program Files\Microsoft\Exchange Server\V15\Bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; 'C:\Admin Tools\HealthChecker\HealthChecker.ps1 -server MQSGMQEXCHPRS01 BuildHtmlServersReport'"

Expected behavior
A clear and concise description of what you expected to happen.
What I would like is to have the script to update, run, and generate the html of the report.

Script Output
If applicable, add the exception that wasn't handled.
Task history shows task completes with an operational code of (2).

Additional context
Add any other context about the problem here.
I have the task configured on the Exchange server itself, using my credentials. Ideally I would like to have it run from our task scheduling cluster (which uses SYSTEM accounts to run.) The nodes of the task scheduling cluster are local admins on the Exchange server but would I need to add them to a role group for the permissions?
Once the html has been output to the folder, I have another script run to pick it up and email it to our ticketing system.

@dpaulson45 dpaulson45 added question Further information is requested Health Checker and removed Issue labels May 9, 2022
@dpaulson45
Copy link
Member

dpaulson45 commented May 9, 2022

You need to do something like this within your task:

.\HeathChecker.ps1 -ScriptUpdateOnly; .\HeathChecker.ps1 -Server "ServerName"; .\HealthChecker.ps1 -BuildHtmlServersReport

This will allow you to get what you want done.

@lusassl-msft
Copy link
Contributor

You can also skip 'C:\Program Files\Microsoft\Exchange Server\V15\Bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto as this is automatically performed by the script.

@dpaulson45 dpaulson45 added the Awaiting feedback Waiting for feedback. label May 9, 2022
@dpaulson45
Copy link
Member

@techieweenie does the above comments provide the information you are looking for?

@dpaulson45
Copy link
Member

@lusassl-msft to create a doc page on how to do this task.

@dpaulson45 dpaulson45 added the Work Item Work Item for project work label May 11, 2022
@techieweenie
Copy link
Author

techieweenie commented May 11, 2022 via email

@lusassl-msft
Copy link
Contributor

@techieweenie we will create a doc page to cover this topic. Will keep you posted here when it's done.

@techieweenie
Copy link
Author

techieweenie commented May 13, 2022 via email

@dpaulson45 dpaulson45 changed the title [Issue] - Health Checker Health Checker how to setup schedule task doc Jun 6, 2022
@lusassl-msft
Copy link
Contributor

I'm working on this now.

@lusassl-msft
Copy link
Contributor

@techieweenie Please have a look and let me know what you think: https://microsoft.github.io/CSS-Exchange/Diagnostics/HealthChecker/RunHCViaSchedTask/

@techieweenie
Copy link
Author

@lucassl-msft

Thank you so much! We are checking it out.

@JeremyTBradshaw
Copy link

@lusassl-msft I'm taking a look at scheduling task for HealthChecker.ps1 and running into Local System (Exchange 2016 server) unable to successfully get into a PSSession due to AuthZ error:

[AuthZRequestId=72fa92b8-4ef1-452a-8ff5-bdf141268094][FailureCategory=AuthZ-CmdletAccessDeniedException] The operation
couldn't be performed because 'DOMAIN\SERVER_NAME$' couldn't be found. For more information, see the
about_Remote_Troubleshooting Help topic.

Looks like this is the solution: https://learn.microsoft.com/en-us/troubleshoot/windows-server/group-policy/authz-fails-access-denied-error-application-access-check

I see in HCScheduledTask that the first step mentioned is to create a service user account. I'm wondering if that is because of this issue which I'm encountering (assuming it's common). The reason I ask is that the main docs page for HealthChecker.ps1 says:

Required Permissions:
Please make sure that the account used is a member of the Local Administrator group. This should be fulfilled on Exchange servers by being a member of the Organization Management group.

Question is: Can you please confirm my understanding is correct? If it is, I'd submit a PR to update the HealthChecker.ps1 and HCScheduledTask pages to include some notes about this. Thanks in advance.

@lusassl-msft
Copy link
Contributor

lusassl-msft commented May 15, 2023

@JeremyTBradshaw I don't think that you can run the scheduled task as local system as this would lead to failures querying the Exchange organization information from AD. Therefore, the recommended way to go is to create a dedicated service account, add it to the Organization Management group or to View-Only Organization Management group and run the scheduled task by using this account.

If you decide to use View-Only Organization Management, you must also add the account to the local administrators group on each Exchange Server (e.g., by the help of a group which is then added to the local administrators or by using a GPO to deploy the account).

@JeremyTBradshaw
Copy link

@lusassl-msft Thanks, and I see now what I was misinterpreting... The "This should be fulfilled on Exchange servers by being a member of the Organization Management group." line in the main docs page for HealthChecker.ps1, I was reading that as if it meant the server itself. I get it now and see it means the user running the script, if they are a member of Org.Mgmt, then they'll also naturally be local admins. It was wishful thinking taking over :).

@lusassl-msft
Copy link
Contributor

No problem. If you think that we should improve the wording, feel free to provide a suggestion to make it more clear.

@JeremyTBradshaw
Copy link

I won't bother updating the wording as I do think it's fine as-is and just had an oversight. But I will paste this link here in case anyone stumbles upon it and finds it useful:

HealthChecker.runHelper.ps1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting feedback Waiting for feedback. Health Checker question Further information is requested Work Item Work Item for project work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants