Change the SCOM 2012 Database Grooming Settings using PowerShell

If you want to use PowerShell to change the Database Grooming settings in SCOM 2012, you can use the following: (just set the value to how many days you want to keep the data before grooming it out of the database)

# The number of days before grooming resolved alerts
Set-SCOMDatabaseGroomingSetting -AlertDaysToKeep 2
# The number of days before grooming availability history
Set-SCOMDatabaseGroomingSetting -AvailabilityHistoryDaysToKeep 2
# The number of days before grooming event data
Set-SCOMDatabaseGroomingSetting -EventDaysToKeep 1
# The number of days before grooming task history
Set-SCOMDatabaseGroomingSetting -JobStatusDaysToKeep 2
# The number of days before grooming maintenance mode history
Set-SCOMDatabaseGroomingSetting -MaintenanceModeHistoryDaysToKeep 2
# The number of days before grooming monitoring job data
Set-SCOMDatabaseGroomingSetting -MonitoringJobDaysToKeep 2
# The number of days before grooming performance data
Set-SCOMDatabaseGroomingSetting -PerformanceDataDaysToKeep 2
# The number of days before grooming state change data
Set-SCOMDatabaseGroomingSetting -StateChangeEventDaysToKeep 4

# Loading the Old 2007 R2 Provider to finish the configuration of things that cannot be done with the new cmdlets

add-pssnapin “Microsoft.EnterpriseManagement.OperationsManager.Client”
new-managementGroupConnection -ConnectionString:YOURMANAGEMENTSERVERHERE
set-location “OperationsManagerMonitoring::”
Set-DefaultSetting -Name ManagementGroup\PartitioningAndGroomingSettings\PerformanceSignatureDaysToKeep -Value 1
Set-DefaultSetting -Name ManagementGroup\PartitioningAndGrooming\SettingsJobStatusDaysToKeep -Value 1

 
Comments

Hi Tim,
I know this post is quite old but still relevant. I am in trying to automating some SCOM configs and therefore this post helped me for SCOM 2016.

There are missing backslashes in
ManagementGroupPartitioningAndGroomingSettingsPerformanceSignatureDaysToKeep and ManagementGroupPartitioningAndGroomingSettingsJobStatusDaysToKeep.

ManagementGroup\PartitioningAndGroomingSettings\PerformanceSignatureDaysToKeep
ManagementGroup\PartitioningAndGroomingSettings\JobStatusDaysToKeep

But nevertheless the usage of old OpsMgr 2007 provider for SCOM 2012 and SCOM 2016 isn’t neccessary (anymore).
I checked that for SCOM 2012 R2 (UR12) and SCOM 2016 (UR3).

# The number of days before grooming Performance signature
Set-SCOMDatabaseGroomingSetting -PerformanceSignatureDaysToKeep 1
# The number of days before grooming task history
Set-SCOMDatabaseGroomingSetting -JobStatusDaysToKeep 2

Regards
Konstantin

Leave a Reply