PowerShell – vCheck Exchange

Previously I have blogged about PowerCLI.  This additional post describes how to use vCheck for Exchange with Exchange 2010.

What is vCheck for Exchange and how should I use it?

vCheck for Exchange is a set of Exchange PowerShell health check scripts that you run daily upon your Exchange 2010 environment; everything that you could think of is already included and then some, with the results being emailed to you.  Be aware that vCheck currently has four variants: vSphere, vCD Audit, Exchange 2010 and SCVMM.

  1. You get vCheck-Exchange from here: Virtu-al.net’s vCheck for Exchange.
  2. Unzip the vCheck-Exchange package to your PowerShell scripts directory on your Exchange CAS, HUB or Mail server.
  3. Make sure that the service account you use has Exchange Administrator Read privileges.
  4. Open PowerCLI and change directory to vCheck-Exchange-master.
  5. You configure vCheck by typing “.\vCheck.ps1 -config” and answering the prompts.
  6. To disable vCheck plugins, just type “.\vCheck-Plugins.ps1” and disable the modules you are not interested in.
  7. Execute the script manually by typing “.\vCheck.ps1” and wait for the script to execute, check for any error messages that may need to be resolved and verify you get the vCheck report emailed to you.
  8. Now you can create a daily task in Task Scheduler (procedure described above).

vCheck-Exchange

How do I Run a PowerShell Script Automatically?

This is the real magic of PowerCLI, using sophisticated scripts with program logic to perform scheduled tasks within vCenter:

  • You have manually executed the script and tested that it works.
  • Go to the Administration Tools folder and execute “Task Scheduler”.
  • Select the “Task Scheduler Library” and you will see the existing tasks.
  • Select “Create Task”.
  • Select the “General” tab and enter the “Name” of the task.
  • Select “Run whether the user is logged in or not”.
  • Select “Run with highest privileges”.
  • Select “Change User or Group” and enter the PowerCLI service account name and password.  Select “OK”.
  • Select the “Trigger” tab and configure the schedule (eg. hourly, daily, weekly, monthly, yearly).  Then press “OK”.
  • Select the “Action” tab and press “New”.
  • Set the “Action” to “Start a program”.
  • For “Program/script”, press “Browse” and select “powershell.exe” in the “C:\Windows\System32\WindowsPowerShell\v1.0\” directory.
  • In the “Add arguments (optional)” field, enter the PowerShell script path, eg. “E:\vCheck-Exchange-master\vCheck.ps1”.  Press “OK”.
  • Select the “Conditions” tab and deselect “Start the task only if the computer is on AC power”.  Press “OK”.
  • Select the “Settings” tab and select “Allow this task to be run on demand”.
  • Select “Stop this task if it runs longer than” and set the period slightly longer than it takes to execute.
  • Select “If the running task does not end when requested, force it to stop”.
  • For “If the task is already running, then the following rule applies” select “Do not start a new instance”.
  • Press “OK” to complete the configuration of the new task.
  • Select the new task from the “Task Scheduler Library” and right mouse click and press “Run”.  Verify that the task executes correctly.
  • The PowerShell script will now execute automatically on the defined schedule.
  • Be mindful of updating your operational procedures to reflect this automated task.

Task_SchedulerTask_Scheduler_Create_Task_GeneralTask_Scheduler_AccountTask_Scheduler_Create_Task_TriggerTask_Scheduler_Create_Task_ActionTask_Scheduler_Create_Task_Condition   Task_Scheduler_Create_Task_SettingsTask_Scheduler_Run

Other Resources

2 thoughts on “PowerShell – vCheck Exchange

  1. After running this scheduled task for about 4 months, we noticed several powershell.exe and and conhost.exe processes stuck running. The vCheck scripts would run completely but these processes would remain. How did you change the script to closes these processes when it finishes?

    • Hello Zack, Thank you for taking the time to read and comment. My use of vCheck in production did not have any “hung” processes. The PowerCLI community is very active, maybe reach out to @alanrenouf or @vtagion. In the meantime, to mitigate this issue you could write a script to scan for hung processes and kill them if found or update your operational procedures to check on a scheduled basis. I am not sure what level of support Microsoft or VMware GSS will give you for an unsupported script, but it is probably worth opening a ticket with both. Regards, Rene.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s