join the MSSQLTips community

MSSQLTips.com - your daily source for SQL Server tips

Google
 
Web mssqltips.com

 
Check the Last SQL Server Backup Date using Windows PowerShell - MSSQLTips

MSSQLTips

MSSQLTips.com - your daily source for SQL Server tips
Welcome to MSSQLTips Sign in | Join | Help
in Search

Check the Last SQL Server Backup Date using Windows PowerShell

Last post 10-22-2009 6:40 PM by bass_player. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 07-01-2009 12:30 AM

    Check the Last SQL Server Backup Date using Windows PowerShell

    This post is related to this tip: Check the Last SQL Server Backup Date using Windows PowerShell

    http://www.mssqltips.com/tip.asp?tip=1784

  • 07-02-2009 8:01 PM In reply to

    Re: Check the Last SQL Server Backup Date using Windows PowerShell

    This is a nice tip thanks.... however.... I have had a SQL Server installation report that it was backing up but no files were created in the folders designated for the backups.

    A suggestion: Can you modify the PowerShell script to report the last date of the log and .bak file from the actual files in the folders?

    Thanks

  • 07-31-2009 4:27 AM In reply to

    Re: Check the Last SQL Server Backup Date using Windows PowerShell

    The recoverymodel is returning NULL thereby causing the line below to fail.

    if ($db.RecoveryModel.Tostring() -eq "SIMPLE")

    But removing ToString() function still returns NULL for the recoverymodel.

    Is there a workaround for this please?

  • 07-31-2009 4:31 AM In reply to

    Re: Check the Last SQL Server Backup Date using Windows PowerShell

     Is it possible to tweak the script for non-english region, especially for excel section?

    I understand changing the regional settings via the control panel will work, but I looking for another way as I don't want to change this setting on my workstation.

  • 08-26-2009 2:29 PM In reply to

    Re: Check the Last SQL Server Backup Date using Windows PowerShell

    hi,

     i have seen ur code. its really gud. is there any chance you can help me out in adding sql server versions+edition and available disk space to this powershell script...? i  need it urgent pls.. can any one help

  • 10-22-2009 6:40 PM In reply to

    Re: Check the Last SQL Server Backup Date using Windows PowerShell

     The Server object has the Edition property that you can use to retrieve the Edition. You can also use the Version, VersionMajor, VersionMinor and VersionString properties for the version

    [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null
    $s = New-Object ('Microsoft.SqlServer.Management.Smo.Server') "LOCALHOST\SQL2000"

    Write-Host "Edition" $s.Edition

    Write-Host "Version" $s.Version

    Write-Host "VersionMajor" $s.VersionMajor

    Write-Host "VersionMinor" $s.VersionMinor

    Write-Host "VersionString" $s.VersionString

     

    For the disk space, it's a simple call to the Win32_WmiObject.The script below can be written in a single line. If you want to read thru a list of computers and list all the logical drives, you can use the -computer parameter in the Get-WmiObject and read thru a text file or something

    Get-WmiObject Win32_LogicalDisk -filter "DriveType=3" | Select DeviceID, @{Name=”Size(GB)”;Expression={”{0:N1}” -f($_.size/1GB)}},@{Name=”Free Space(GB)”;Expression={”{0:N1}” -f($_.freespace/1GB)}}

     

Page 1 of 1 (6 items)