SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


I want get html report from log shipping


I want get html report from log shipping

Author
Message
manu.manohar033
manu.manohar033
Valued Member
Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)

Group: General Forum Members
Points: 54 Visits: 86
I want to get HTML report from log shipping, here is my script... please modify it

##setup data source
$dataSource1 = "MANU\PRACTICE" ##SQL instance name
$database1 = "MASTER" ##Database name
$dataSource2 = "MANU" ##SQL instance name
$database2 = "MASTER" ##Database name
$sqlCommand = "exec sp_help_log_shipping_monitor" ##The T-SQL command to execute
$TableHeader = "Log_shipping_status" ##The title of the HTML page
$Todaydate = (Get-date).toString("yyyyMMddhhmmss")
$FileDir="D:\logshipping\" #Directory where you need to save Reports
$OutputFile = $FileDir+$Todaydate+"-LogshippingReport.html" ##The file location
##set HTML formatting
$Header = @"
<style>
TABLE {border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}
TR:Nth-Child(Even) {Background-Color: #dddddd;}
TH {border-width: 1px;padding: 3px;border-style: solid;border-color: black;background-color: #6495ED;}
TD {border-width: 1px;padding: 3px;border-style: solid;border-color: black;}
</style>
<title>
Log_shipping_status
</title>
"@
$body = @"
"@
$pre="<h1>Log_shipping_status</h1>"
##Create a string variable with all our connection details
$connectionDetails = "Provider=sqloledb; " +
"Data Source=$dataSource; " +
"Initial Catalog=$database; " +
"Integrated Security=SSPI;"

##Connect to the data source using the connection details and T-SQL command we provided above, and open the connection
$connection = New-Object System.Data.OleDb.OleDbConnection $connectionDetails
$command = New-Object System.Data.OleDb.OleDbCommand $sqlCommand,$connection
$connection.Open()

##Get the results of our command into a DataSet object, and close the connection
$dataAdapter = New-Object System.Data.OleDb.OleDbDataAdapter $command
$dataSet = New-Object System.Data.DataSet
$dataAdapter.Fill($dataSet)
$connection.Close()

##Return all of the rows and pipe it into the ConvertTo-HTML cmdlet, and then pipe that into our output file
$dataSet.Tables | Select-Object -Expand Rows |
ConvertTo-HTML -Property server, database_name,last_backup_file, last_copied_file, last_restored_file -head $Header -body $body -PreContent $pre|
Out-File $OutputFile
manu.manohar033
manu.manohar033
Valued Member
Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)

Group: General Forum Members
Points: 54 Visits: 86

This is my output, Please help me. I want to get copy and restore also
Steve Jones
Steve Jones
SSC Guru
SSC Guru (332K reputation)SSC Guru (332K reputation)SSC Guru (332K reputation)SSC Guru (332K reputation)SSC Guru (332K reputation)SSC Guru (332K reputation)SSC Guru (332K reputation)SSC Guru (332K reputation)

Group: Administrators
Points: 332236 Visits: 20119
What doesn't work?

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
AlexSQLForums
AlexSQLForums
SSCrazy Eights
SSCrazy Eights (8.1K reputation)SSCrazy Eights (8.1K reputation)SSCrazy Eights (8.1K reputation)SSCrazy Eights (8.1K reputation)SSCrazy Eights (8.1K reputation)SSCrazy Eights (8.1K reputation)SSCrazy Eights (8.1K reputation)SSCrazy Eights (8.1K reputation)

Group: General Forum Members
Points: 8143 Visits: 2476
You suppose to execute this script in the destination server to get the data for those columns.

Alex S
RandomStream
RandomStream
Right there with Babe
Right there with Babe (747 reputation)Right there with Babe (747 reputation)Right there with Babe (747 reputation)Right there with Babe (747 reputation)Right there with Babe (747 reputation)Right there with Babe (747 reputation)Right there with Babe (747 reputation)Right there with Babe (747 reputation)

Group: General Forum Members
Points: 747 Visits: 486

What scripting language is this?
Why don't you create a SQL Server Agent job and have it email you in html format directly?


Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (226K reputation)SSC Guru (226K reputation)SSC Guru (226K reputation)SSC Guru (226K reputation)SSC Guru (226K reputation)SSC Guru (226K reputation)SSC Guru (226K reputation)SSC Guru (226K reputation)

Group: General Forum Members
Points: 226098 Visits: 40424
RandomStream - Thursday, January 4, 2018 4:50 PM

What scripting language is this?
Why don't you create a SQL Server Agent job and have it email you in html format directly?



Looks like PowerShell.
However, I may be wrong.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Sue_H
Sue_H
SSC-Dedicated
SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)

Group: General Forum Members
Points: 33601 Visits: 9564
Lynn Pettis - Thursday, January 4, 2018 5:47 PM
RandomStream - Thursday, January 4, 2018 4:50 PM

What scripting language is this?
Why don't you create a SQL Server Agent job and have it email you in html format directly?



Looks like PowerShell.
However, I may be wrong.


Mastering it already...yes it's Powershell. Sir Smile

Sue



Sue_H
Sue_H
SSC-Dedicated
SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)

Group: General Forum Members
Points: 33601 Visits: 9564
manu.manohar033 - Thursday, December 21, 2017 8:29 AM
I want to get HTML report from log shipping, here is my script... please modify it

##setup data source
$dataSource1 = "MANU\PRACTICE" ##SQL instance name
$database1 = "MASTER" ##Database name
$dataSource2 = "MANU" ##SQL instance name
$database2 = "MASTER" ##Database name
$sqlCommand = "exec sp_help_log_shipping_monitor" ##The T-SQL command to execute
$TableHeader = "Log_shipping_status" ##The title of the HTML page
$Todaydate = (Get-date).toString("yyyyMMddhhmmss")
$FileDir="D:\logshipping\" #Directory where you need to save Reports
$OutputFile = $FileDir+$Todaydate+"-LogshippingReport.html" ##The file location
##set HTML formatting
$Header = @"
<style>
TABLE {border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}
TR:Nth-Child(Even) {Background-Color: #dddddd;}
TH {border-width: 1px;padding: 3px;border-style: solid;border-color: black;background-color: #6495ED;}
TD {border-width: 1px;padding: 3px;border-style: solid;border-color: black;}
</style>
<title>
Log_shipping_status
</title>
"@
$body = @"
"@
$pre="<h1>Log_shipping_status</h1>"
##Create a string variable with all our connection details
$connectionDetails = "Provider=sqloledb; " +
"Data Source=$dataSource; " +
"Initial Catalog=$database; " +
"Integrated Security=SSPI;"

##Connect to the data source using the connection details and T-SQL command we provided above, and open the connection
$connection = New-Object System.Data.OleDb.OleDbConnection $connectionDetails
$command = New-Object System.Data.OleDb.OleDbCommand $sqlCommand,$connection
$connection.Open()

##Get the results of our command into a DataSet object, and close the connection
$dataAdapter = New-Object System.Data.OleDb.OleDbDataAdapter $command
$dataSet = New-Object System.Data.DataSet
$dataAdapter.Fill($dataSet)
$connection.Close()

##Return all of the rows and pipe it into the ConvertTo-HTML cmdlet, and then pipe that into our output file
$dataSet.Tables | Select-Object -Expand Rows |
ConvertTo-HTML -Property server, database_name,last_backup_file, last_copied_file, last_restored_file -head $Header -body $body -PreContent $pre|
Out-File $OutputFile


The script itself runs fine - just ran it.
The issue looks like something with log shipping itself. Manually execute sp_help_log_shipping_monitor in the master database on the primary - if there are no rows for the copy or the restore then it's that process itself.
Check the LS_copy job and the LS_restore job on the secondary and make sure SQL Server Agent is running on the secondary.

Sue



Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search