One of my colleagues recently asked how to determine the last restart time of a Business Central service. If you've ever needed to check when a Business Central service was last restarted, PowerShell provides a quick and efficient way to do this.
The PowerShell Script
The following PowerShell command retrieves the restart time of all running Microsoft Dynamics 365 Business Central services:
Get-CimInstance -ClassName Win32_Service |
Where-Object { $_.Name -like "MicrosoftDynamicsNavServer*" } |
Select-Object Name, ProcessId, @{Name="Last Restarted";Expression={(Get-Process -Id $_.ProcessId).StartTime}}
Explanation of the Script:
- Get-CimInstance -ClassName Win32_Service – Retrieves all Windows services running on the system.
- Where-Object { $_.Name -like "MicrosoftDynamicsNavServer*" } – Filters out only those services related to Business Central (previously NAV) by name.
- Select-Object Name, ProcessId, @{Name="Last Restarted";Expression={(Get-Process -Id $_.ProcessId).StartTime}} – Extracts the service name, process ID, and retrieves the start time of the corresponding process, which indicates when the service was last restarted.
Running the Script
Simply open PowerShell with administrator privileges and run the above command. It will output a list of Business Central services along with their last restart time.
*This post is locked for comments