Chat now with support
Chat with Support

LiteSpeed for SQL Server 8.9.5 - Security and Compliance Guide

Log Reader - CLI Commands

The Log Reader command-line interface (CLI) operates with various Log Reader objects (these object are named Quest.LogReader.SqlServer.Wrappers.[ObjectType], where [ObjectType] stands for the type-specific part of the name). For most commands, these objects are used as input parameters and other commands return them as execution results. You can build scripts using these objects and CLI commands. 

Log Reader has the following commands:

Command

Description

Get-QLRSqlRegServer

Reads a configuration file, generates a list of registered SQL Server objectsClosed, and writes the list to a pipeline.

Add-QLRSqlRegServer

Registers a new SQL Server instance and adds its connection parameters to the configuration file.

Tip: You can use the connection parameters to connect to the registered SQL Server by setting the connection mode to Predefined.

Remove-QLRSqlRegServer

Removes a registered SQL Server from a configuration file.

Set-QLRSqlSrvAgent

Installs, uninstalls, or repairs the Log Reader  server components on a remote SQL Server instance.

Get-QLRSqlSrvAgent

Retrieves version and installation status of the Log Reader server components on a computer where a registered SQL Server instance resides and writes results to a pipeline. The results are returned for a server component status objectClosed.

New-QLRSqlReader

 

Returns a Log Reader objectClosed with the transaction log loaded into it.

Tip: Use this command to create a Log Reader object to use in other CLI commands.

Get-QLRSqlLogFile

Generates a list of log file objectsClosed for all log files that are attached to the database, and writes the list to a pipeline.

Get-QLRSqlVirtualLogFile

Generates a list of virtual log file objectsClosed for all virtual log files in an open Log reader objectClosed, and writes the list to a pipeline.

Get-QLRSqlCommand

Reads DML/DDL commands from an open Log Reader objectClosed, generates a command objectClosed for each DML/DDL command, and writes the commands to a pipeline.

Get-QLRSqlRecord

Reads log records from an open Log Reader objectClosed, generates a log record objectClosed for each record, and writes the records to a pipeline.

Get-QLRSqlTransaction

Reads transactions from an open Log Reader objectClosed, generates a transaction objectClosed for each transaction, and writes the transactions to a pipeline.

Out-QLRSqlCsv

Out-QLRSqlHtml

Out-QLRSqlXml

Out-QLRSqlDatabase

Exports input objects into CSV (Out-QLRSqlCsv), HTML (Out-QLRSqlHtml), XML (Out-QLRSqlXml) file or into a database (Out-QLRSqlDatabase).  

Valid input objects are:

  • DML/DDL command objectClosed

  • Log record objectClosed

  • Transaction objectClosed

To get help for a command, use the following:

  • For detailed information on a command, type "get-help [command name] -detailed" in PowerShell.
  • For technical information on a command, type "get-help [command name] -full" in PowerShell.

Tip: You can script and schedule execution of most frequently used command sequences. For more information, see Script Log Reader Commands.

Examples

  1. Install the Log Reader server components:

    $ cred = Get-Credential

    Set-QLRSqlSrvAgent -Install -Credential $cred

  2. Read all DML/DDL commands in a log and export results to an XML file:

    $lr = New-QLRSqlReader -Online

    Get-QLRSqlCommand $lr | Out-QLRSqlXml C:\out.xml -Full

    $lr.Close()

  3. Read DML commands only and load results into a database:

    $lr = New-QLRSqlReader -Online

    Get-QLRSqlCommand $lr | Out-QLRSqlDatabase -ServerName -DatabaseName -TableName -LoginMode SQLServer login password    

    $lr.Close()

    or

    Get-QLRSqlCommand $lr | Where-Object {$_.Type -eq ”DML”} | Out-QLRSqlDatabase -ServerName

    -DatabaseName -TableName -LoginMode Windows 

    $lr.Close()

    $lr = New-QLRSqlReader -Server ServerName -Database AdventureWorksDW -LoginMode Windows -Online Get-QLRSqlCommand $lr | Out-QLRSqlDatabase -Server ServerName -Database LogReaderTest -Table ExportData_log -LoginMode SQLServer login password

    $lr.Close()

    or

    Get-QLRSqlCommand $lr | Where-Object {$_.Type -eq "DML"} | Out-QLRSqlDatabase -Server ServerName -Database LogReaderTest -Table ExportData_log -LoginMode Windows

    $lr.Close()

    Note: The Log Reader uses an existing database to create a table with a specified name.

  4. Read the full log:

    $lr = New-QLRSqlReader -Online

    Get-QLRSqlRecord $lr | more

    $lr.Close()

  5. Read the list of transactions:

    $lr = New-QLRSqlReader -Online

    Get-QLRSqlTransaction $lr | more

    $lr.Close()

 

Related Topics

Log Reader PowerShell Snap-In

Script Log Reader Commands

Related Documents

The document was helpful.

Select Rating

I easily found the information I needed.

Select Rating