{"title":"Monitoring Business Central Server Events with PowerShell","url":"https://jonas-paprotka.de/docs/dev-itpro/administration/monitor-server-events-with-powershell/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/administration/monitor-server-events-with-powershell, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/administration/monitor-server-events-with-powershell","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Learn how to use PowerShell to monitor Business Central Server instances","date":"2024-10-26","meta":{"topic":"how-to"},"outline":[{"level":1,"title":"Monitoring Business Central Server Events with PowerShell","slug":"monitoring-business-central-server-events-with-powershell","at":0,"chars":5917},{"level":2,"title":" PowerShell Get-WinEvent cmdlet","slug":"powershell-get-winevent-cmdlet","at":328,"chars":1116},{"level":2,"title":"To use the Get-WinEvent Cmdlet to view events","slug":"to-use-the-get-winevent-cmdlet-to-view-events","at":1444,"chars":1254},{"level":2,"title":" To enable the Debug Logs from Windows PowerShell","slug":"to-enable-the-debug-logs-from-windows-powershell","at":2698,"chars":717},{"level":2,"title":"Filtering Business Central Server events","slug":"filtering-business-central-server-events","at":3415,"chars":2083},{"level":3,"title":"Example 1","slug":"example-1","at":3719,"chars":486},{"level":3,"title":"Example 2","slug":"example-2","at":4205,"chars":1293},{"level":2,"title":"Related information","slug":"related-information","at":5498,"chars":419}],"text":"# Monitoring Business Central Server Events with PowerShell\n> APPLIES TO: Business Central on-premises\nEvents that occur on the Business Central Server instances are recorded in event logs on the computer that is running Business Central Server. You can view the events by using Windows PowerShell as described in this article.\n##  PowerShell Get-WinEvent cmdlet\nYou can use the Get-WinEvent cmdlet of Windows PowerShell to view Business Central Server instance events and trace events in the event logs and event tracing log files on the Business Central Server computer. The Get-WinEvent cmdlet retrieves the same events that can be viewed in Event Viewer under Applications and Services Logs > Microsoft > DynamicsNAV (see Monitoring Business Central Server Events Using Event Viewer<monitor-server-events-windows-event-log>).\nThe Get-WinEvent cmdlet includes several parameters that enable you to filter the events that you view and specify how the events are displayed. Windows PowerShell enables you can create scripts that perform complex operations for extracting and displaying specific event data. For more information about the Get-WinEvent cmdlet, see https://learn.microsoft.com/powershell/module/microsoft.powershell.diagnostics/get-winevent.\nFor more information about installing and getting started with Windows PowerShell, see Getting Started with Windows PowerShell<https://learn.microsoft.com/powershell/scripting/overview>.\n## To use the Get-WinEvent Cmdlet to view events\n1. If you want to view events in a Debug log, ensure that the log is enabled. The Admin and Operational logs are enabled by default.\n For information, see To enable the Business Central Server Debug Log from Windows PowerShell<#EnableLog>.\n2. On the computer that is running Business Central Server, start Window PowerShell.\n See Starting Windows PowerShell<https://go.microsoft.com/fwlink/?LinkID=513794>.\n3. At the command prompt, enter the `Get-WinEvent` command. The following table provides some simple example commands.\n To view|Command\n Events in the all DynamicsNAV > Server logs|`Get-WinEvent -ProviderName Microsoft-DynamicsNAV-Server`\n Events in the all DynamicsNAV > Common logs|`Get-WinEvent -ProviderName Microsoft-DynamicsNav-Common`\n Events in the DynamicsNAV > Server > Admin log|`Get-WinEvent -LogName Microsoft-DynamicsNAV-Server/Admin`\n Events in the DynamicsNAV > Common > Admin log|`Get-WinEvent -LogName Microsoft-DynamicsNav-Common/Admin`\n Events in the Business Central Server Operational log|`Get-WinEvent -LogName Microsoft-DynamicsNAV-Server/Operational`\n Trace events in the Business Central Server Debug log|`Get-WinEvent -LogName Microsoft-DynamicsNAV-Server/Debug -Oldest`\n##  To enable the Debug Logs from Windows PowerShell\nThere are two debug logs for Business Central: Microsoft-DynamicsNAV-Server/Debug and Microsoft-DynamicsNav-Common/Debug.\n1. On the computer that is running Business Central Server, start Window PowerShell as an administrator.\n2. At the command prompt, run the following commands:\n ```\n wevtutil.exe set-log \"Microsoft-DynamicsNAV-Server/<Debug>\" /q:true /e:true\n ```\n ```\n wevtutil.exe set-log \"Microsoft-DynamicsNav-Common/<Debug>\" /q:true /e:true\n ```\n> TIP\n> You can also enable the Debug log from Event Viewer. See Enable Analytic and Debug Logs<https://learn.microsoft.com/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/cc749492(v=ws.11)>.\n## Filtering Business Central Server events\nYou can filter the events that you view in a Business Central Server log by setting the FilterXpath parameter of the Get-WinEvent cmdlet. The following examples illustrate how you can use the FilterXpath parameter to filter the Business Central Server events.\n### Example 1\nThe following example uses the Get-WinEvent cmdlet to view errors in the Business Central Server Admin log for the tenant MyTenant1 on the server instance MyNavServerInstance1.\n```powershell\nGet-WinEvent -LogName 'Microsoft-DynamicsNAV-Server/Admin' -FilterXPath \"*[System[(Level=2)]] and *[EventData[Data[@Name='tenantId'] and (Data = 'MyTenant1')]] and *[EventData[Data[@Name='serverInstanceName'] and Data='MyNavServerInstance1']]\" | Format-List -Property Message-\n```\n### Example 2\nThe following is an example of a Windows PowerShell script that you can create and run to view trace events in the Business Central Server Debug log. The script returns the start and stop AL function trace events that take more than four seconds to execute on the tenant MyTenant1 of the server instance MyNavServerInstance1.\n```\n$maxAllowedSeconds = 4\n\n$xPath = \"*[System[(EventID = 400 or EventID = 401)]] and \" +\n         \"*[EventData[Data[@Name='tenantId'] and (Data  = 'MyTenant1')]] and \" +\n         \"*[EventData[Data[@Name='serverInstanceName'] and Data='MyNavServerInstance1']]\"\n\n$events = Get-WinEvent -LogName 'Microsoft-DynamicsNAV-Server/Debug' -FilterXPath $xPath -Oldest -MaxEvents 10000\n\nWrite-Host \"List of AL functions that took more than $maxAllowedSeconds  seconds to execute :\" -ForegroundColor DarkYellow\n\nfor($i = 0; $i -lt  $events.Length; $i+=2)\n{\n   $seconds = ($events[$i + 1].TimeCreated - $events[$i].TimeCreated).Seconds\n\n   if ($seconds -ge $maxAllowedSeconds )\n   {\n     Write-Host $events[$i].Message `r`n -ForegroundColor Magenta\n   }\n}\n```\nYou can create the script by using, for example, Notepad or Windows PowerShell Integrated Scripting Environment \\(ISE\\). You save the script as .ps1 file type, and then run it from the Windows PowerShell.\n## Related information\nMonitoring Business Central Server Events<monitor-server-events>\nBusiness Central Server Trace Events<server-trace-events>\nMonitoring Business Central Server<monitor-server>\nMonitoring Business Central Server Using Performance Counters<monitor-server-using-performance-counters>\nEvent Viewer<https://learn.microsoft.com/windows/security/threat-protection/microsoft-defender-atp/event-error-codes>"}