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

  • 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

  •  This is output, I want add secondary server output also

  • I want to copy and restore output, please modify script and help me...   Thanks in advance

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply