Check the Health of Your Retail Service in Dynamics 365 for Operations with PowerShell

By Josh Lee | April 25, 2017

A Production environment for Dynamics 365 for Operations (D365) is hosted by Microsoft and the underlying physical virtual machines are not exposed to the client. This is in stark contrast to a UAT, Test or Dev environment hosted by Microsoft for D365. The latter environments expose the RDP connection information as well as credentials which allow direct access to the VM’s as well as the underlying AOS services. This can make troubleshooting live issues a challenge in some scenarios when logging into a server is not possible.

If you have a Dynamics 365 for Operations with Retail deployment, it can be especially critical to be able to quickly check the health of the Retail Service (real-time service).  The real-time service is the backbone for the Microsoft Point of Sale (MPOS) client. It provides the communication channel between MPOS and the retail channels. Lifecycle Services (LCS) provides an Environment Monitoring portal for each service (the Retail Server is shown below), however, this requires logging into LCS, navigating to the Environment Monitoring Page and clicking on the Retail server.  You could bookmark the page for faster access, but this still won’t select the specific service view as it defaults to the AOS view.


A quick real-time service check can be performed by:

  1. Opening a web browser
  2. Entering: https://[PROD_URL]/healthcheck?testname=ping
  3. Hitting enter

This will perform a quick ping check on both the database and real-time service.  The results will show if the database and real-time service is up:


Or down:



With PowerShell, you could create a simple script that checks the service state, schedule it in Windows Task Scheduler to check it on a specific frequency and get failure notifications via email.  Here is a simple example of how you might accomplish this. Please note that this is a very basic example and is simply meant to demonstrate how you might accomplish this task in a few lines of code.  In a production scenario you would want a more robust solution and would not want to be prompted for credentials to email out the notification (for example use an encrypted file for the -Credential parameter rather than entering it as shown in the code below):

#Check the status of D365 Database and Retailtime Service
$retailServiceCheck = Invoke-WebRequest -URI

#DBCheck Results Text
$DBCheck = @($retailServiceCheck.ParsedHtml.getElementsByTagName("Table")).rows[1].cells[2].innertext

#RetaltimeServiceCheck Results Text
$RealtimeServiceCheck = @($retailServiceCheck.ParsedHtml.getElementsByTagName("Table")).rows[2].cells[2].innertext

IF($DBCheck -ne "Success")
    $sendEmail = $true
    $subject = "CRITICAL - D365 PING Failure!"
    $body = "Dynamics 365 for Operations DBCheck Failed.  Status is - $DBCheck"

ELSEIF($DBCheck -ne "Success")
    $sendEmail = $true
    $subject = "CRITICAL - D365 PING Failure!"
    $body = "Dynamics 365 for Operations RealtimeSerivceCheck Failed.  Status is - $RealtimeServiceCheck"

Send-MailMessage -SmtpServer '' -from' -to '' -body $body -bodyashtml -Priority High -UseSsl -Subject $subject -Credential Get-Credential

And here is the email notification informing you of an outage condition:


Under the terms of this license, you are authorized to share and redistribute the content across various mediums, subject to adherence to the specified conditions: you must provide proper attribution to Stoneridge as the original creator in a manner that does not imply their endorsement of your use, the material is to be utilized solely for non-commercial purposes, and alterations, modifications, or derivative works based on the original material are strictly prohibited.

Responsibility rests with the licensee to ensure that their use of the material does not violate any other rights.

Start the Conversation

It’s our mission to help clients win. We’d love to talk to you about the right business solutions to help you achieve your goals.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!