locked
PowerShell script to list of all SQL 2008 databases with their RecoveryModel status RRS feed

  • Question

  • Hi All

    Thought this would be easy .. and to pull back the SQL instance name and database names is precisely that.

    SCOM2007R2

    get-monitoringclass -name "Microsoft.SQLServer.2008.Database" | get-monitoringobject | Select Path, DisplayName

    SCOM2012 beta

    Get-SCOMClass -name 'Microsoft.SQLServer.2008.Database' | Get-SCOMClassInstance | Select Path, DisplayName | Sort -Property Path, DisplayName

    But how can I get the RecoveryModel property back as well?

    If I do a | export-csv then the resultant csv file shows that the Recovery Model property is listed as[Microsoft.SQLServer.Database].RecoveryModel but putting that in my Select statement doesn't work (I just get blank entries). I suspect that I might need to link back up the class food chain to pull the Recovery Model property but wondered if there was an easier way.

    Thanks!

    Graham


    New SCOM 2012 Blog! - http://www.systemcentersolutions.com/blog/
    View OpsMgr tips and tricks at http://systemcentersolutions.wordpress.com/
    Sunday, August 7, 2011 11:24 AM

Answers

  • Sorry to update my own post - bad form. But Marco Shaw, a PowerShell MVP came up with the answer. The following will work for SCOM 2012 beta:

    Get-SCOMClass -name 'Microsoft.SQLServer.2008.Database' | Get-SCOMClassInstance | Select Path, DisplayName *.RecoveryModel | Sort -Property Path, DisplayName

    Not sure if there is a neater way but certainly if you do see a field in square brackets e.g. [Microsoft.SQLServer.Database].RecoveryModel then to get it into a Select statement, use *.RecoveryModel

     

     

     

     


    New SCOM 2012 Blog! - http://www.systemcentersolutions.com/blog/
    View OpsMgr tips and tricks at http://systemcentersolutions.wordpress.com/
    • Marked as answer by Vivian Xing Thursday, August 18, 2011 9:13 AM
    Sunday, August 7, 2011 10:22 PM