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 objects (Quest.LogReader.SqlServer.Wrappers.ServerWrapper), 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 object (Quest.LogReader.SqlServer.Wrappers.AgentWrapper). |
|
Returns a Log Reader object (Quest.LogReader.SqlServer.Wrappers.LogReaderSSWrapper) 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 objects (Quest.LogReader.SqlServer.Wrappers.LogFileWrapper) 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 objects (Quest.LogReader.SqlServer.Wrappers.VirtualLogFileWrapper) for all virtual log files in an open Log reader object (Quest.LogReader.SqlServer.Wrappers.LogReaderSSWrapper), and writes the list to a pipeline. |
Get-QLRSqlCommand |
Reads DML/DDL commands from an open Log Reader object (Quest.LogReader.SqlServer.Wrappers.LogReaderSSWrapper), generates a command object (Quest.LogReader.SqlServer.Wrappers.CommandWrapper) for each DML/DDL command, and writes the commands to a pipeline. |
Get-QLRSqlRecord |
Reads log records from an open Log Reader object (Quest.LogReader.SqlServer.Wrappers.LogReaderSSWrapper), generates a log record object (Quest.LogReader.SqlServer.Wrappers.RecordWrapper) for each record, and writes the records to a pipeline. |
Get-QLRSqlTransaction |
Reads transactions from an open Log Reader object Quest.LogReader.SqlServer.Wrappers.LogReaderSSWrapper), generates a transaction object (Quest.LogReader.SqlServer.Wrappers.TransactionWrapper) for each transaction, and writes the transactions to a pipeline. |
Exports input objects into CSV (Out-QLRSqlCsv), HTML (Out-QLRSqlHtml), XML (Out-QLRSqlXml) file or into a database (Out-QLRSqlDatabase). Valid input objects are: |
To get help for a command, use the following:
Tip: You can script and schedule execution of most frequently used command sequences. For more information, see Script Log Reader Commands.
Install the Log Reader server components:
$ cred = Get-Credential
Set-QLRSqlSrvAgent -Install -Credential $cred
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()
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.
Read the full log:
$lr = New-QLRSqlReader -Online
Get-QLRSqlRecord $lr | more
$lr.Close()
Read the list of transactions:
$lr = New-QLRSqlReader -Online
Get-QLRSqlTransaction $lr | more
$lr.Close()
© ALL RIGHTS RESERVED. Feedback Terms of Use Privacy Cookie Preference Center