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


I want to get output from two different instance in log shipping through power shell


I want to get output from two different instance in log shipping through power shell

Author
Message
manu.manohar033
manu.manohar033
SSC Journeyman
SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)

Group: General Forum Members
Points: 78 Visits: 120
I want to get output from two instance. Please modify my power shell script. Here is my script

##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
SSC Journeyman
SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)

Group: General Forum Members
Points: 78 Visits: 120
This is output, I want add secondary server output also
manu.manohar033
manu.manohar033
SSC Journeyman
SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)

Group: General Forum Members
Points: 78 Visits: 120
I want to copy and restore output, please modify script and help me... Thanks in advance
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