< Back

Get-DbatoolsLog

Mon Jan 13, 2020 11:45 am

NAME Get-DbatoolsLog



SYNOPSIS

Returns log entries for dbatools





SYNTAX

Get-DbatoolsLog [[-FunctionName] <String>] [[-ModuleName] <String>] [[-Target] <System.Object>] [[-Tag]

<System.String[]>] [[-Last] <Int>] [-LastError <Switch>] [[-Skip] <Int>] [[-Runspace] <Guid>] [[-Level]

<Sqlcollaborative.Dbatools.Message.MessageLevel[]>] [-Raw <Switch>] [-Errors <Switch>] [<CommonParameters>]





DESCRIPTION

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





PARAMETERS

-Errors [<Switch>]

Instead of log entries, the error entries will be retrieved



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-FunctionName [<String>]

Default: "*"

Only messages written by similar functions will be returned.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Last [<Int>]

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'



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-LastError [<Switch>]

Only retrieves the last error message type written.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Level [<Sqlcollaborative.Dbatools.Message.MessageLevel[]>]

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).



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-ModuleName [<String>]

Default: "*"

Only messages written by commands from similar modules will be returned.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Raw [<Switch>]

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

formatting.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Runspace [<Guid>]

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



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Skip [<Int>]

How many executions to skip when specifying '-Last'.

Has no effect without the '-Last' parameter.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Tag [<System.String[]>]

Only messages containing one of these tags will be returned.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Target [<System.Object>]

Only messages handling the specified target will be returned.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





Tags: Module, Support

Author: Friedrich Weinmann (@FredWeinmann)



Website: https://dbatools.io

Copyright: (c) 2018 by dbatools, licensed under MIT

License: MIT https://opensource.org/licenses/MIT



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



RELATED LINKS

https://dbatools.io/Get-DbatoolsLog