Menu Close

Delete your empty Console folders in SCOM

One thing I find in a lot of customer environments, is empty folders.

Every time a MP is created in the console, SCOM creates a folder for that MP.  These folders are often not used, empty, and just clog up the console.

You can delete these manually and I recommend it.  If there are no views under a folder, there is no use for that folder.  Delete it!

If you have a huge number of folders to delete, you can use PowerShell.  This script came out of a discussion on Reddit in the SCOM Discussion subreddit.  Credits to _CyrAz


This script will delete folders from your MP’s in your SCOM management group.  It only uses the criteria that if no views exist, no folder is needed.  Review the list it generates and make sure it looks correct.

It will prompt you and you must confirm, before it does anything.  It also will backup your unsealed MP’s first to make sure you have a good backup before making changes:



Here is the example script:

Clear-Host #Get Management Group Name $MGConnSetting = New-Object Microsoft.EnterpriseManagement.ManagementGroupConnectionSettings("localhost") $MG = New-Object Microsoft.EnterpriseManagement.ManagementGroup($MGConnSetting) $MGName = $MG.Name #Get Date $date = get-date -format M.d.yyyy $BackupPath = "C:\MPBackup\$MGName\$date" #Make the directory for today if it does not already exist IF (!(Test-Path $BackupPath)) { Write-Host "Creating MP Backup Path at $BackupPath" mkdir $BackupPath } #Get all unsealed MPs $mps = Get-SCOMManagementPack | where {$_.Sealed -eq $false} Write-Host "Backing up Unsealed MPs to $BackupPath" $mps | Export-SCOMManagementPack -Path:$BackupPath #Empty array $FolderDeleteList = @() $FolderDeleteCount = 0 Write-Host "`nBelow is the list of folders to be deleted:" Write-Host "Folder Name | MP DisplayName | MP Name`n" #Build a list of all MPs with an empty Folder FOREACH ($mp in $mps) { $MPName = $mp.Name $MPDisplayName = $mp.DisplayName $Folders = $mp.getfolders() $Views = $mp.GetViews() [int]$FolderCount = $Folders.count [int]$ViewsCount = $Views.Count #Check to see of there is a single folder but no views defined in the MP IF (($FolderCount -eq 1) -and ($ViewsCount -eq 0) ) { # This MP has a single folder and no views. Add it to the list for review $Folder = $folders[0] $FolderDisplayName = $Folder.DisplayName [string]$FolderString = "$FolderDisplayName | $MPDisplayName | $MPName" Write-Host $FolderString $FolderDeleteCount ++ } } IF ($FolderDeleteCount -eq 0) { Write-Host "There are no folders to delete that were found to be empty" } ELSE { #Ask the user to confirm before deleting folders in all MPs [string]$Confirm = Read-Host "`nPlease type CONFIRM to delete all folders which were found to be empty" IF ($Confirm -ceq "CONFIRM") { #This is a match. Delete Folders FOREACH ($mp in $mps) { $MPName = $mp.Name $MPDisplayName = $mp.DisplayName $Folders = $mp.getfolders() $Views = $mp.GetViews() [int]$FolderCount = $Folders.count [int]$ViewsCount = $Views.Count #Check to see of there is a single folder but no views defined in the MP IF (($FolderCount -eq 1) -and ($ViewsCount -eq 0) ) { # This MP has a single folder and no views. Delete it $Folder = $folders[0] $FolderDisplayName = $Folder.DisplayName [string]$FolderString = "$FolderDisplayName | $MPDisplayName | $MPName" Write-Host "Deleting: $FolderString" #Set folder status to PendingDelete $Folder.status = "PendingDelete" #Apply Changes to the MP $mp.AcceptChanges() } } } ELSE { #This is not a match Write-Host "`nAction was not confirmed. Doing nothing" } }


  1. Sunny

    Hello Kevin,
    Thanks for make our like easy with your blogs. Could you please write something for getting a view or alert on SCOM for server which are not rebooted in last 30 days.

    • Bert Pinoy

      Hi Sunny,

      This can be easily done by using this management pack: It allows you to create monitors, rules, etc. using powershell.
      This example can help you create a monitor to check what servers have an uptime of 30 days or more:

      # Any Arguments specified will be sent to the script as a single string.
      # If you need to send multiple values, delimit them with a space, semicolon or other separator and then use split.

      $ScomAPI = New-Object -comObject “MOM.ScriptAPI”
      $PropertyBag = $ScomAPI.CreatePropertyBag()

      # Example of use below, in this case return the length of the string passed in and we’ll set health state based on that.
      # Since the health state comparison is string based in this template we’ll need to create a state value and return it.
      # Ensure you return a unique value per health state (e.g. a service status), or a unique combination of values.

      $uptimedays = ((get-date) – (gcim Win32_OperatingSystem). LastBootUpTime).Days

      if($uptimedays -ge 30) {

      # Send output to SCOM

      Then its a matter of matching the state values to either critical/warning and healthy.

  2. sharma Mitra

    Hi Kevin,

    your articles are amazing and SCOM admin life so easy . Please write some articles on HP OneView with SCOM integration Kit and Dell ESX monitoring with SCOM.

  3. Raoul

    Thanks for this script. Alltough I delete these empty folders from time to time, I still had some.

    The script found a few of them, and deleted them. But for some reason it does not find all my empty folders.

    • Kevin Holman

      Sometimes an empty folder might have something unexpected, like a HMTL 5 web based dashboard, or anything that references the folder in the MP.

Leave a Reply

Your email address will not be published.