SCOMHelper.psm1

<#
Version History:
2026.05.26.1539 - Export-SCOMEffectiveMonitoringConfigurationReport: fixed CSV header class column order and -WhatIf early-return/verbose behavior.
2025.10.30.1258 -
  Get-SCOMDWPerformanceData: Fixed verbose parameter handling.
  Get-SCOMDWPerformanceDataSignature: Fixed empty set return issue.
  Improved verbose output for Get-SCOMRelatedMonitoringObjects.
2025.09.19.1626 - Added Get-SCOMRelatedMonitoringObjects, Get-SCOMDWPerformanceDataSignature, Get-SCOMDWPerformanceData
2025.09.09.2048 - Fixed Get-SCOMManagementPackXml to clean up temp files correctly.
2025.09.08.0000 - Added Get-SCOMGroupMember
2025.09.02.1153 - Added new function Get-SCOMManagementPackXml to SCOMHelper.psm1 module.
2025.07.31.1304 - Updated Help documentation for Function Get-SCOMPerformanceData.
2025.07.30.1157 - Fixed 'System.__ComObject' text removal from tmp .xml dataitem file.
2025.07.10.1001 - Fixed Get-SCOMObjectAvailability to get DW SQL name correctly.
2025.07.07 - 1.44: Added Get-SCOMObjectAvailability function to SCOMHelper.psm1. Also added Invoke-CLSqlCmd to Private.ps1
2025.06.30 - Added Get-SCOMPerformanceData
2024.01.30.1702 - Updated Show-SCOMPropertyBag to exit gracefully if the file does not exist.
2023.02.28 - Added Reset-SCOMInstanceHealth
2022.10.11.1247 - Added Start-SCOMTrace to support mgmt servers. Typically this module will only exist on SCOM mgmt servers.
2022.06.20 - Added new function: Convert-MAML2HTML
2022.06.10 - Added Get-SCOMRunningWorkflows. Improved Export-SCOMEffectiveMonitoringConfigurationReport function to eliminate empty Path issue.
2020.11.19 - Update-SCOMComputerGroup: improved a little bit. Update-OMGroupDiscovery2: added default Mgmtservername value and failure logging.
2020.08.18 - Added new function: Update-SCOMComputerGroup. Fixed small issue with New-SCOMClassGraph.
2020.08.11 - Added a Private.ps1 file to include common functions.
2020.07.22 - Remove 'Import-Module OperationsManager'
#>


# ------------------------------------------------------------------------------
# Phase 2 loader.
# All public commands now live in Public\<Name>.ps1 (one file per exported function).
# Private helpers live in Private\Private.ps1.
# This script imports Private first, then every Public\*.ps1 in deterministic order,
# then performs module-init (temp folder) and registers aliases.
# ------------------------------------------------------------------------------

. (Join-Path $PSScriptRoot 'Private\Private.ps1')

Get-ChildItem -LiteralPath (Join-Path $PSScriptRoot 'Public') -Filter '*.ps1' -File -ErrorAction SilentlyContinue |
    Sort-Object Name |
    ForEach-Object { . $_.FullName }

$TempFolder = (Join-Path (Join-Path $env:Windir "Temp") SCOMHelper )
If (-NOT (Test-Path -Path $TempFolder -PathType Container)){
  Write-Host "Attempting to create temp folder: $TempFolder" -F DarkCyan
  Try{
    New-Item -ItemType Directory -Path $TempFolder -Force -ErrorAction Stop
  }Catch{
    Write-Host "Failed to create temp directory. Please run this tool as administrator." -F Red
  }
}

New-Alias -Name 'Export-EffectiveMonitoringConfiguration' -Value 'Export-SCOMEffectiveMonitoringConfigurationReport' -ErrorAction Ignore
New-Alias -Name 'Disable-SCOMAllEventRules' -Value 'Start-SCOMOverrideTool' -ErrorAction Ignore
New-Alias -Name  'Get-SCOMRunningWorkflows' -Value 'Get-SCOMAgentWorkflows' -ErrorAction Ignore

Export-ModuleMember -Alias *