• Rao.V (4/10/2012)


    Hi all,

    I am using idea of script you mentioned to verify the backup status of backup files location in different location. Same like RESTORE VERIFYONLY.

    The 'C:\Temp\Paths.txt' is having backup file locations of different servers. The code is working perfectly when I use one path but its failing to execute when more than one path is specified.

    Please help me on what modifications to be done to the script in order verify the backup file status of different locations.

    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null

    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoExtended") | Out-Null

    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo") | Out-Null

    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoEnum") | Out-Null

    $server = New-Object ("Microsoft.SqlServer.Management.Smo.Server") ("servername")

    $dbBackup = new-Object ("Microsoft.SqlServer.Management.Smo.Backup")

    $dbRestore = new-object ("Microsoft.SqlServer.Management.Smo.Restore")

    $a = Get-Content "C:\Temp\paths.txt"

    foreach ($path in $a)

    {

    $dbRestore.Devices.AddDevice($path, "File")

    if (!($dbRestore.SqlVerify($server))){

    $body = $path

    $emailFrom = "email"

    $emailTo = "email"

    $subject = "Backup Files Health"

    $smtpServer = "serverip"

    $smtp = new-object Net.Mail.SmtpClient($smtpserver)

    $smtp.Send($emailFrom, $emailTo, $subject, $body)

    Exit

    }

    }

    Thanks

    Vinay

    Exit

    gsc_dba