commands

^

Get-DbatoolsLog

Author Friedrich Weinmann (@FredWeinmann)
Availability Windows, Linux, macOS

 

Synopsis

Returns log entries for dbatools

Description

Returns log entries for dbatools. Handy when debugging or developing a script using it.

Syntax

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>]

 

Examples

 

Example: 1
PS C:\> Get-DbatoolsLog

Returns all log entries currently in memory.

Example: 2
PS C:\> Get-DbatooolsLog -LastError

Returns the last log entry type of error.

Example: 3
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.

Example: 4
PS C:\> Get-DbatoolsLog -Tag "fail" -Last 5

Returns all log entries within the last 5 executions that contained the tag "fail"

Optional Parameters

-FunctionName

Default: "*" Only messages written by similar functions will be returned.

Alias
Required False
Pipeline false
Default Value *
-ModuleName

Default: "*" Only messages written by commands from similar modules will be returned.

Alias
Required False
Pipeline false
Default Value *
-Target

Only messages handling the specified target will be returned.

Alias
Required False
Pipeline false
Default Value
-Tag

Only messages containing one of these tags will be returned.

Alias
Required False
Pipeline false
Default Value
-Last

Only messages written by the last X executions will be returned. Uses Get-History to determine execution. Ignores Get-message commands. By default, this will also include messages from other runspaces. If your command executes in parallel, that's useful. If it doesn't and you were offloading executions to other runspaces, consider also filtering by runspace using '-Runspace'

Alias
Required False
Pipeline false
Default Value 0
-LastError

Only retrieves the last error message type written.

Alias
Required False
Pipeline false
Default Value False
-Skip

How many executions to skip when specifying '-Last'. Has no effect without the '-Last' parameter.

Alias
Required False
Pipeline false
Default Value 0
-Runspace

The guid of the runspace to return messages from. By default, messages from all runspaces are returned. Run the following line to see the list of guids: Get-Runspace | ft Id, Name, InstanceId -AutoSize

Alias
Required False
Pipeline false
Default Value
-Level

Limit the message selection by level. Message levels have a numeric value, making it easier to select a range: -Level (1..6) Will select the first 6 levels (Critical - SomewhatVerbose).

Alias
Required False
Pipeline false
Default Value
-Raw

By default, messages such as SQL statements are flattened. Use raw to see the output without flattened formatting.

Alias
Required False
Pipeline false
Default Value False
-Errors

Instead of log entries, the error entries will be retrieved

Alias
Required False
Pipeline false
Default Value False

 

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.