Backup Status for Multiple SQl Servers.

Hi All,
What changes are required in the below script - so that it displays the backup result for
multiple SQL SERVERS.
--Databases with data backup over 24 hours old
SELECT
   CONVERT(CHAR(100), SERVERPROPERTY('Servername')) AS Server,
   msdb.dbo.backupset.database_name,
   MAX(msdb.dbo.backupset.backup_finish_date) AS last_db_backup_date,
   DATEDIFF(hh, MAX(msdb.dbo.backupset.backup_finish_date), GETDATE()) AS [Backup Age (Hours)]
FROM    msdb.dbo.backupset
WHERE     msdb.dbo.backupset.type = 'D' 
GROUP BY msdb.dbo.backupset.database_name
HAVING      (MAX(msdb.dbo.backupset.backup_finish_date) < DATEADD(hh, - 24, GETDATE())) 
UNION 
--Databases without any backup history
SELECT     
   CONVERT(CHAR(100), SERVERPROPERTY('Servername')) AS Server, 
   master.dbo.sysdatabases.NAME AS database_name, 
   NULL AS [Last Data Backup Date], 
   9999 AS [Backup Age (Hours)] 
FROM
   master.dbo.sysdatabases LEFT JOIN msdb.dbo.backupset
       ON master.dbo.sysdatabases.name  = msdb.dbo.backupset.database_name
WHERE msdb.dbo.backupset.database_name IS NULL AND master.dbo.sysdatabases.name <> 'tempdb'
ORDER BY 
   msdb.dbo.backupset.database_name
Thanks..!!

Hi Prashanth,
what location do I need to provide for SQL Server for link: http://blogs.technet.com/b/heyscriptingguy/archive/2011/05/02/use-powershell-to-report-sql-server-backup-status.aspx
{ $location = "SQLSERVER:\SQL\$SQLInstance\Databases" }
else
{ $location = "SQLSERVER:\SQL\$SQLInstance\DEFAULT\Databases" }    ??

Similar Messages

  • SQL Agent jobs status for multiple servers using Powershell.

    Hi All,
    I am following website link:
    http://www.toadworld.com/platforms/sql-server/b/weblog/archive/2013/09/17/powershell-script-to-monitor-a-service-on-a-group-of-servers-html-formatted-email-output.aspx
    I require to gather status details about all the SQL Agent jobs in the environment on multiple SQL Servers.
    I tried to edit the script using:
    [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO")
    $sqlServerName = 'localhost\developer'
    $sqlServer = New-Object Microsoft.SqlServer.Management.Smo.Server($sqlServerName)
    foreach($job in $sqlServer.JobServer.Jobs)
        $job | select Name, OwnerLoginName, IsEnabled, LastRunDate, LastRunOutcome, DateCReated, DateLastModified
    but SQL Agent jobs are not reflecting in the mail output...
    requesting help...!!
    Thanks in Advance.
    Hunt

    I've created a new script for you.  Let me know if you've any questions
    Create the function
    Function Get-SQLJobHTMLReport
    param(
    [String]$ComputerList,[string]$Outputfile,[String]$To,[String]$From,[string]$SMTPMail
    New-Item -ItemType file $Outputfile -Force
    # Function to write the HTML Header to the file
    Function writeHtmlHeader
    param($fileName)
    $date = ( get-date ).ToString(‘yyyy/MM/dd’)
    Add-Content $fileName “<html>”
    Add-Content $fileName “<head>”
    Add-Content $fileName “<meta http-equiv=’Content-Type’ content=’text/html; charset=iso-8859-1′>”
    Add-Content $fileName ‘<title>Service Status Report </title>’
    add-content $fileName ‘<STYLE TYPE=”text/css”>’
    add-content $fileName “<!–”
    add-content $fileName “td {“
    add-content $fileName “font-family: Tahoma;”
    add-content $fileName “font-size: 11px;”
    add-content $fileName “border-top: 1px solid #999999;”
    add-content $fileName “border-right: 1px solid #999999;”
    add-content $fileName “border-bottom: 1px solid #999999;”
    add-content $fileName “border-left: 1px solid #999999;”
    add-content $fileName “padding-top: 0px;”
    add-content $fileName “padding-right: 0px;”
    add-content $fileName “padding-bottom: 0px;”
    add-content $fileName “padding-left: 0px;”
    add-content $fileName “}”
    add-content $fileName “body {“
    add-content $fileName “margin-left: 5px;”
    add-content $fileName “margin-top: 5px;”
    add-content $fileName “margin-right: 0px;”
    add-content $fileName “margin-bottom: 10px;”
    add-content $fileName “”
    add-content $fileName “table {“
    add-content $fileName “border: thin solid #000000;”
    add-content $fileName “}”
    add-content $fileName “–>”
    add-content $fileName “</style>”
    Add-Content $fileName “</head>”
    Add-Content $fileName “<body>”
    add-content $fileName “<table width=’100%’>”
    add-content $fileName “<tr bgcolor=’#CCCCCC’>”
    add-content $fileName “<td colspan=’4′ height=’25′ align=’center’>”
    add-content $fileName “</td>”
    add-content $fileName “</tr>”
    add-content $fileName “</table>”
    # Function to write the HTML Header to the file
    Function writeTableHeader
    param($fileName)
    Add-Content $fileName “<tr bgcolor=#CCCCCC>”
    Add-Content $fileName “<td width=’10%’ align=’center’>ServerName</td>”
    Add-Content $fileName “<td width=’50%’ align=’center’>Name</td>”
    Add-Content $fileName “<td width=’10%’ align=’center’>OwnerLoginName</td>”
    Add-Content $fileName “<td width=’10%’ align=’center’>IsEnabled</td>”
    Add-Content $fileName “<td width=’10%’ align=’center’>LastRunDate</td>”
    Add-Content $fileName “<td width=’10%’ align=’center’>LastRunOutcome</td>”
    Add-Content $fileName “<td width=’10%’ align=’center’>DateCReated</td>”
    Add-Content $fileName “<td width=’10%’ align=’center’>DateLastModified</td>”
    Add-Content $fileName “</tr>”
    Function writeHtmlFooter
    param($fileName)
    Add-Content $fileName “</body>”
    Add-Content $fileName “</html>”
    Function writeDiskInfo
    param($filename,$Servername,$name,$OwnerLoginName,$IsEnabled,$LastRunDate,$LastRunOutcome,$DateCReated,$DateLastModified)
    Add-Content $fileName “<tr>”
    Add-Content $fileName “<td bgcolor=’#FF0000′ align=left ><b>$servername</td>”
    Add-Content $fileName “<td bgcolor=’#FF0000′ align=left ><b>$name</td>”
    Add-Content $fileName “<td bgcolor=’#FF0000′ align=left ><b>$OwnerLoginName</td>”
    Add-Content $fileName “<td bgcolor=’#FF0000′ align=left ><b>$IsEnabled</td>”
    Add-Content $fileName “<td bgcolor=’#FF0000′ align=left ><b>$LastRunDate</td>”
    Add-Content $fileName “<td bgcolor=’#FF0000′ align=left ><b>$LastRunOutcome</td>”
    Add-Content $fileName “<td bgcolor=’#FF0000′ align=left ><b>$DateCReated</td>”
    Add-Content $fileName “<td bgcolor=’#FF0000′ align=left ><b>$DateLastModified</td>”
    Add-Content $fileName “</tr>”
    writeHtmlHeader $Outputfile
    Add-Content $Outputfile “<table width=’100%’><tbody>”
    Add-Content $Outputfile “<tr bgcolor=’#CCCCCC’>”
    Add-Content $Outputfile “<td width=’100%’ align=’center’ colSpan=8><font face=’tahoma’ color=’#003399′ size=’2′><center><strong> SQL Server Agent Job Details</strong></font></td>”
    Add-Content $Outputfile “</tr>”
    writeTableHeader $Outputfile
    #Change value of the following parameter as needed
    Foreach($ServerName in (Get-Content $ComputerList))
    $sqlServer = New-Object Microsoft.SqlServer.Management.Smo.Server($ServerName)
    foreach($item in $sqlServer.JobServer.Jobs)
    Write-Host $sqlServer $item.name $item.OwnerLoginName $item.IsEnabled $item.LastRunDate $item.LastRunOutcome $item.DateCReated $item.DateLastModified
    writeDiskInfo $Outputfile $sqlServer $item.name $item.OwnerLoginName $item.IsEnabled $item.LastRunDate $item.LastRunOutcome $item.DateCReated $item.DateLastModified
    Add-Content $Outputfile “</table>”
    writeHtmlFooter $Outputfile
    Function sendEmail
    param($from,$to,$subject,$smtphost,$htmlFileName)
    [string]$receipients=”$to”
    $body = Get-Content $htmlFileName
    $body = New-Object System.Net.Mail.MailMessage $from, $receipients, $subject, $body
    $body.isBodyhtml = $true
    $smtpServer = $smtphost
    $smtp = new-object Net.Mail.SmtpClient($smtphost)
    $smtp.Send($body)
    write-output “Email Sent!!”
    $date = ( get-date ).ToString(‘yyyy/MM/dd’)
    sendEmail -from $From -to $to -subject “Service Status – $Date” -smtphost $SMTPMail -htmlfilename $Outputfile
    Get-SQLJobHTMLReport -ComputerList f:\powersql\server.txt -SMTPMail hq.abc.com -To [email protected] -From [email protected] -Outputfile F:\Powersql\jobs.htm
    --Prashanth

  • Running a Select query against multiple sql servers using SSIS script task.

    Hi Guys,
    I need to fetch data from multiple sql servers using  SSIS scirpt task inside a foreach container.
    is there anyway i can build dynamic sql connections using ssis variables inside SSIS script task in each loop
    Please guide me or refer any blogs so that i will try..
    Thanks in advance.

    Your only options is using .net code, then it will be no different than using a console app in a loop.
    using (SqlConnection connection = new SqlConnection(connectionString))
    connection.Open();
    Console.WriteLine("ServerVersion: {0}", connection.ServerVersion);
    Console.WriteLine("State: {0}", connection.State);
    and so forth for each connection string
    the connection string would come from the ForEach loop
    Arthur My Blog

  • Required to take periodic backup status report from SQL server

    Dear All,
    I need to take periodic database backup status of all sql server instance in different domain. But, i am doing it by logging into all sql server manually.
    We can do it through option called ' Managed server' in sql server by connecting required server.
    But, I want to know the script and any other option in sql server to connect all sql instance in different domain group to take backup status report in single run.
    I need your help here and share the experience if you implemented ever in your environment.

    see
    http://www.mssqltips.com/sqlservertip/1601/script-to-retrieve-sql-server-database-backup-history-and-no-backups/
    You can use above scripts to capture the information
    For automated execution wrap it in a procedure with INSERT statement to dump the results onto a table and call the procedure from sql agent job to execute  it based on a predefined schedule.
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Can't change the 'compilation status' for multiple items in iTunes 8.

    Hi there,
    I've got an issue regarding the disappearance of the compilation 'tick box' when changing multiple items. Its there when you click on 'get info' for the individual track but its no longer there (in iTunes 8) when I want to change the compilation 'status' for multiple tracks at a time.
    In iTunes 7 I selected all the tracks and changed their compilation status by accident, but now, in iTunes 8 I can't change this without going through my library, track by track!.
    Please help.
    Thanks,
    Fred

    Multiple Get info now has tabs - look on the options tab.

  • NT startup parmaters for multiple weblogic servers started as a service

    I have the need to start multiple weblogic servers, using NT services.
    I have created a second folder with a properties file listening on another
    port.
    I am using the following startup parameter
    -J-Dweblogic.system.name=Test
    My question, this works when I type the startup parameter, is their anyway
    to have this automatically entered
    on server startup.
    Is their a registry setting to make this permanent
    Thanks

    The answer is...
    - Use a product to turn applications into an NT Service (e.g.
    ServiceMill)
    - Directly run the Weblogic Server Java class via that application
    --> As many WLs on one machine as you like.
    Send mail if you need specific details.
    Best regards
    Daniel Hoppe
    -----Original Message-----
    From: [email protected] (Ed) [mailto:[email protected]]
    Posted At: Wednesday, August 30, 2000 2:34 AM
    Posted To: install
    Conversation: NT startup parmaters for multiple weblogic servers started
    as a service
    Subject: Re: NT startup parmaters for multiple weblogic servers started
    as a service
    I wish that was the case.
    The problem is, while you enter the startup parameter once, it only
    is good for that startup of the weblogic server,
    The next time the server reboots and the services start, unless you
    re-enter the startup parameter -J-Dweblogic.system.name=Foldername
    The weblogic server starts using the wrong properties file.
    Is their anyway using NT services to have the correct instance of WL
    to start everytime.
    I have checked this newsgroup and this question has been posted
    before, but so far no one seems to have the answer.
    I know in a production eniviorment someone must be running more that
    one instance of a WL server as a service, Hopefully their is an
    answer on how this is done.
    Thank you
    Kumar Allamraju <[email protected]> wrote:
    Not that i know of.
    but you are specifying this startup parameter only one time too!!!
    Kumar
    None of your bussines wrote:
    I have the need to start multiple weblogic servers, using NT
    services.
    I have created a second folder with a properties file listening onanother
    port.
    I am using the following startup parameter
    -J-Dweblogic.system.name=Test
    My question, this works when I type the startup parameter, is theiranyway
    to have this automatically entered
    on server startup.
    Is their a registry setting to make this permanent
    Thanks

  • Backup status for DPF in DBACOCKPIT missing ...

    Hi
    Does anyone observed missing backup and log archive (Backup and Recovery / Overview) status for DPF database after patching to:
    SAP_BASIS    702    0014    SAPKB70214    SAP Basis Component in Solution Manager SP11 ?
    Another function appeared is splitting single backup session row into multiple rows - displaying how many I/O sessions were used during backup - don't know if it is a bug or a new feature ?
    Created ticket in OSS but look like they don't know how to proceed.

    Well , another issue was not starting IGS , i've updated component BC-FES-IGS  to newest version 7.20.07 using JSPM - but this could be due to wrong configuratio nupdate during SUM patching ...
    Also performed DB upgrade to 10.5FP3 and two notes were needed seperately to SolMan main one:
    1951951 and 1881171.
    BTW i've recently made new Solman SP11  installation using  newest SPM on 10.5FP3 DB and choosen DB tablespaces compression new option (it is mentioned that STATIC compression will be in use but as 10.5 has default ADAPTIVE one all tables are compressed using ADAPTIVE).
    DB had  42 GB after finished installation  (very nice result) and 62GB after applying patches to SP11 and running SGEN.

  • Timemachine backup status on multiple macs?

    Hi,
    I am backing up a little below 10 machines with Timemachine on a network drive.
    I would like to create a small weekly report to see when the last successful backup was done on each mac.... but cannot find anything on this?
    Is there a shareware that could that? Or a little script?
    Tx for your help!
    Nicolas
    Message was edited by: nico_147

    Hi Prashanth,
    what location do I need to provide for SQL Server for link: http://blogs.technet.com/b/heyscriptingguy/archive/2011/05/02/use-powershell-to-report-sql-server-backup-status.aspx
    { $location = "SQLSERVER:\SQL\$SQLInstance\Databases" }
    else
    { $location = "SQLSERVER:\SQL\$SQLInstance\DEFAULT\Databases" }    ??

  • Determine connection status of multiple database servers

    We have mutliple database servers that MAY/MAY NOT be connected to the network at any time. I need to determine which DB servers are available to connect to. I have a stored procedure that does a HOST TNSPING command and checking the results through the FORM_SUCCESS function. That works but the response time is too slow, due to taking too long to timeout. What we attempted to do was to issue a HOST PING command, but because of the 16 bit factor, the FORM_SUCCESS did not recognize the results of the PING. I tried to capture the results of a PING into a variable, but had no success. Bottom line, we don't care how it gets done, we just need to be able to determine, as quickly as possible, what database servers are connected.

    Microsoft SQL allows for clustering of SQL databases, so for
    instance two servers connected to a fileshare and a virtual address
    shared across the two physical boxes. Database connections are made
    to the virtual addres which will then be handled by the active
    node. Becuase a database is ultimately a file(s) on a disk it can
    only be attached to one node at a time so you end up with an
    active/inactive cluster.

  • Changing status for multiple assets

    Hi,
    After a quick search I cant find anything that relates to my question.
    I want to be able to quickly assign a status to multiple assets while in list view.
    Is this possible ?
    The only way I can see to do it at the moment is to individually open each asset and then navigate to the 'review and approve' tab and then change the stauts ---much too slow and tedious.
    Thanks,
    Dan

    It's not possible with any single built-in command.
    But one way to do it is set up a Response that is triggered by a Subscription:
    + Create a Response to Set Asset Metadata to the status you want.
    + Then create a Subscription to an Asset, triggered on Analyzed and Modified, calling your Response--but don't create any Asset Filter.
    Now you can select a group of assets, Analyze them, and they will get their metadata reset to what you have configured in the Response.
    Some considerations:
    + Make sure other people aren't analyzing assets at the same time, since you didn't put in any restrictions. For the same reason, you will probably want to disable the Subscription after you are done, or else in the future some people might get confused why their status is changing unexpectedly when they analyze an asset.
    + If you have multiple pages of assets you want to change, you may have to do it several times or enter a search term to make it easier to find them. If you're talking about changing hundreds or thousands of assets, you might want to consider doing it with an external script instead.
    + You could add an extra measure of safety by adding an Asset Filter if you know in advance what some of the metadata will have to be. (But don't set Trigger if changed.)
    + Don't analyze assets in the List view--it will lock up your FCSvr session.

  • Can we set "IN PROCESSu201D status for multiple users for a single workitem?

    Hi,
    As per my client current scenario every work item will be sent to 3 useru2019s (One is the supervisor of the other two users). If any one of the user executes the work item it will automatically call a Ztransaction and displays the screen. When the user without taking any action, he presses the BACK button (in Ztransaction) and comes out of the transaction. Then the workitems for the rest of the users will disappear from there inboxes.
    But my client requirement is such that, whenever the user click on back button the workitem should be "IN PROCESS" status for two users(One is the supervisor and one who executes the workitem) out of  3 users possessing the workitems.
    Please provide me any advice to the above requirement.
    Thanks in advance,
    Ranganadh

    I think this can be done either by putting a check whether the user does anything. If he does a flag should be set which can be used in the Codition Tab of the Activity step that will prevent the workitem from completion.
    Thanks
    Arghadip

  • How to customize search in WS 7 and for multiple virtual servers?

    I'm not clear on how to customize search results pages in Sun Web Server 7. The documentation (the Adminstrator's Guide, page 215) says:
    You can take a look at the default search application located at /bin/https/webapps/search as a sample application
    but I'm not seeing any such thing. I did a find . -name search -type d from the server root and instance root but the only search directories I'm seeing are subdirectories within the generated directory and they look like system generated jsps that I shouldn't touch (So I didn't :-)
    So one question is, where is the default app? A second question is, how do we set up different branding for different virtual servers?
    We're currently using WS 6.1 and it has a field in the GUI for the directory containing the web app to use for search. That seems to have disappeared in WS 7.
    Any help would be appreciated. Thanks.
    Dave

    I don't use the search engine, so I'm afriad I don't have direct experience here.
    What I'd probably do is modify the app so that it looks at the Host data to determine which directory it should point to for graphics, formatting, etc. You could also use the obj.conf with variables to pull graphics from directories appropriately branded. Something like:
    1) Create "additional doc directory" for images
    2) Find the entry in the obj.conf that points to the new directory
    3) Modify the path to something like /path/to/$host/images
    4) Make sure you create directories like:
    /path/to/foobar.com/images/
    /path/to/www.foobar.com/images/
    /path/to/baz.com/images/
    /path/to/www.baz.com/images/

  • Multiple Backup Locations for Multiple Lightroom Databases

    I currently work with two lightroom databases but when I back up the databases, the backups get stored in the same Lightroom Backups folder. The two backups are stored in separate sub-folders but the actual database files have the same name. Thus, the only way to know which backup is for which database if to note the times that the backups were created and use this to determine which backup applies to which database.
    It would seem like the actual backup files could be named as per the associated database or the backup location could be specified for each database so that there is less chance for a mistake if a database needs to be restored.
    Thanks in advance,
    Dave Mayfield

    Thanks for your reply.
    I need the have each LOS ( Location of sale or location of delivery) of Business Partner because we will deliver items for the LOS and not for BP.
    As we also need to control (serial numbers) items & services ( field management) I also need to have the LOS as BP.
    As example:
    BP name AAA have 30 LOS.
    BP AAA bought 2000 items.
    BP AAA ask us to old theses items in warehouse.
    BP AAA request to delivery a x quantity in LOS 1, 2,3,4,...
    The invoice went to BP AAA, but the deliveries will be to each LOS of BP AAA.
    As I said we need to have the field services working side-by-side with serials numbers and services for each LOS of our BP AAA.
    So, we have subcustomers from big customer BP AAA.
    Do we have any way of having all subcustomers(LOS) as BP, along with the real customer AAA?
    Thanks in advance,

  • Reversing TECO status for Multiple WBS elements

    Hi,
    Question on setting and then reversing TECO status for a WBS element.
    When a project is closed technically in project builder, all underlaying items (wbs, network/activity) are technically closed as well.
    When you try to undo this, only the status of the top element is changed, not the underlaying items.
    Is there any way in which we get the underlaying items changed as well (mass change is not an option)
    Regards,
    Jatinder Bansal

    You can try two methods :-
    1.  Open project in project builder, Select project definition and then go to WBS Overview under project definition, now select all WBS Element and then undo TECO status. Now all the WBS status will be updated. But, this will not have any effect on network and its activities.
    2. Open the project in planning board, now select all the objects, now undo the TECO status. This will change the status of all selected objects like WBS,Network and activites....

  • Explain Plan for Multiple SQL

    Hi ,
    Our db version is Oracle 8i and looking for solution.
    I have multiple select sql statments and need to get the explain plan for all statments.
    Is it possible to take explain plan for all statments one time? If so please provide the steps.
    Thanks.
    Happy Halloween.

    Not sure exactly you are looking. But if you do
    set autotrace on
    from sqlplus and put all the query in a script, you should get all explain plan in one shot. You can spool the output to a file.

Maybe you are looking for