Scripted checking of SCCM Backups

This is a script that parses the smsbkup.log and outputs results (in html) and the relevant portions of the file to the specified folder. The idea being that the with a small bit of tweaking you could have the report hosted on  a webserver to check or emailed (there will be a post on emailing in Powershell later) to you.

This is best run from the central primary under credentials that have access to the other sites.

Note: The script requires UNC paths for the $fpath variable as it is expecting be be run remotely.

Note2: This script was written for SCCM 2007 and not for SCCM 2012, however thanks to one of my readers, Satish, the following should fix that:
Change
if ($content | where {$_ -like "Backup task completed successfully*"}) {
to
if ($content | where{$_ -like "*SQL Backup task completed successfully*"}) {

Note3:
Potential Dates issues with SCCM 2012 R2. Thanks to Marius for the update.
Change
$cdate = $cdate.adddays($days) | get-date -format “ddd MMM dd”
to (this is probably US specific and will probably vary depending on locale)
$cdate = $cdate.adddays($days) | get-date -format “MM-dd-yyyy”

Script:

2 thoughts to “Scripted checking of SCCM Backups”

  1. Thanks Marius.

    The script was developed against 2007 R2 on a UK system so it is possible MS have changed the format of the timestamps in the logs.

    get-date will return the date in the following format “24 March 2014 13:11:44”, we then add the days to that date object and then pipe the object into get-date in order to produce the following format “Mon Mar 24” all of which are not locale specific.

    $cdate gets the latter of the two formats mentioned above and is then used as a filter to return only the lines containing that.

    Ryan

  2. Hi Ryan, thanks for sharing the script. For SCCM 2012 R2 (probably SCCM 2012 in general) i had to change this line here
    $cdate = $cdate.adddays($days) | get-date -format “ddd MMM dd”
    to
    $cdate = $cdate.adddays($days) | get-date -format “MM-dd-yyyy”

    Since my date format in the log was “MM-dd-yyyy” 03-20-2014. Not sure if the log file uses the date format of the locale setting on the server.

    Greets
    Marius

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This blog is kept spam free by WP-SpamFree.