Author | Friedrich Weinmann (@FredWeinmann) |
Availability | Windows, Linux, macOS |
Want to see the source code for this command? Check out Get-DbatoolsLog on GitHub.
Want to see the Bill Of Health for this command? Check out Get-DbatoolsLog.
Retrieves internal log entries and error messages from dbatools module execution
Retrieves log entries from dbatools' internal logging system, allowing you to troubleshoot command execution and track what happened during script runs. Use this when dbatools commands aren't behaving as expected or when you need to see detailed execution information for debugging purposes. The function can filter logs by specific functions, modules, targets, execution history, or message levels, making it easier to isolate issues during SQL Server automation tasks.
Get-DbatoolsLog
[[-FunctionName] <String>]
[[-ModuleName] <String>]
[[-Target] <Object>]
[[-Tag] <String[]>]
[[-Last] <Int32>]
[-LastError]
[[-Skip] <Int32>]
[[-Runspace] <Guid>]
[[-Level] {Critical | Important | Output | Significant | VeryVerbose | Verbose | SomewhatVerbose | System | Debug | InternalComment | Warning}]
[-Raw]
[-Errors]
[<CommonParameters>]
PS C:\> Get-DbatoolsLog
Returns all log entries currently in memory.
PS C:\> Get-DbatoolsLog -LastError
Returns the last log entry type of error.
PS C:\> Get-DbatoolsLog -Target "a" -Last 1 -Skip 1
Returns all log entries that targeted the object "a" in the second last execution sent.
PS C:\> Get-DbatoolsLog -Tag "fail" -Last 5
Returns all log entries within the last 5 executions that contained the tag "fail"
Filters log entries to show only messages from dbatools functions matching this pattern. Supports wildcards.
Use this when troubleshooting specific commands like 'Backup-DbaDatabase' or when you want to see all backup-related functions with 'Backup-Dba*'.
Alias | |
Required | False |
Pipeline | false |
Default Value | * |
Filters log entries to show only messages from modules matching this pattern. Supports wildcards.
Use this when working with multiple PowerShell modules and you only want to see dbatools-related log entries.
Alias | |
Required | False |
Pipeline | false |
Default Value | * |
Filters log entries to show only messages related to a specific target object like a server name, database name, or other SQL Server component.
Use this when troubleshooting issues with a particular SQL Server instance or database to see only relevant log entries.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Filters log entries to show only messages that contain any of the specified tags.
Use this to find specific types of operations like 'backup', 'restore', or 'migration' when tracking down issues with particular dbatools workflows.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Returns log entries from only the last X PowerShell command executions in your current session.
Use this to focus on recent activity when troubleshooting the most recent dbatools commands you ran. Excludes Get-DbatoolsLog commands from the execution count to avoid confusion.
Alias | |
Required | False |
Pipeline | false |
Default Value | 0 |
Returns only the most recent error message from the dbatools logging system.
Use this as a quick way to see what went wrong with your last dbatools command execution without scrolling through all log entries.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
Specifies how many recent executions to skip when using the -Last parameter.
Use this when you want to see log entries from earlier executions, like '-Last 3 -Skip 2' to see the 3rd, 4th, and 5th most recent executions.
Alias | |
Required | False |
Pipeline | false |
Default Value | 0 |
Filters log entries to show only messages from the specified PowerShell runspace GUID.
Use this when troubleshooting parallel or background dbatools operations to isolate messages from specific execution threads.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Filters log entries by message severity level (Critical, Error, Warning, Info, Verbose, etc.).
Use this to focus on specific severity levels, like only errors and warnings, or to see verbose details during troubleshooting. Supports arrays and ranges like (1..6).
Alias | |
Required | False |
Pipeline | false |
Default Value |
Returns log messages in their original format without flattening multiline content like SQL statements.
Use this when you need to see the exact formatting of SQL queries or error messages for detailed troubleshooting.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
Returns error entries from dbatools' error tracking system instead of regular log entries.
Use this when you specifically need to see exceptions and errors that occurred during dbatools command execution, separate from informational logging.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |