Update StackMonkey.ps1

This commit is contained in:
2025-06-29 00:47:11 -04:00
parent d0a703539a
commit a4c0628291

View File

@@ -220,25 +220,30 @@ function Write-LogHelper {
} }
} }
# ─────────────────────────────────────────────────────────────────────────
# WRITE-LOG HYBRID (single definition, chooses at runtime)
# ─────────────────────────────────────────────────────────────────────────
function Write-LogHybrid { function Write-LogHybrid {
[CmdletBinding()] [CmdletBinding()]
param( param(
[Parameter(Mandatory)][string]$Message, [Parameter(Mandatory=$true)][string]$Message,
[ValidateSet("Info","Warning","Error","Success","General")] [ValidateSet("Info","Warning","Error","Success","General")]
[string]$Level = "Info", [string]$Level = "Info",
[string]$TaskCategory = "GeneralTask", [string]$TaskCategory = "GeneralTask",
[switch]$LogToEvent [switch]$LogToEvent
) )
# at *call* time* pick the right implementation if ( Get-Command -Name Write-Log -ErrorAction SilentlyContinue ) {
if ( Get-Command Write-Log -ErrorAction SilentlyContinue ) { # SVSMSP modules Write-Log is available
Write-Log @PSBoundParameters Write-Log -Message $Message -Level $Level -TaskCategory $TaskCategory -LogToEvent:$LogToEvent
} }
else { else {
Write-LogHelper @PSBoundParameters # fall back to your helper
Write-LogHelper -Message $Message -Level $Level -TaskCategory $TaskCategory -LogToEvent:$LogToEvent
} }
} }
#endregion #endregion
# ───────────────────────────────────────────────────────────────────────── # ─────────────────────────────────────────────────────────────────────────