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 {
[CmdletBinding()]
param(
[Parameter(Mandatory)][string]$Message,
[Parameter(Mandatory=$true)][string]$Message,
[ValidateSet("Info","Warning","Error","Success","General")]
[string]$Level = "Info",
[string]$TaskCategory = "GeneralTask",
[switch]$LogToEvent
)
# at *call* time* pick the right implementation
if ( Get-Command Write-Log -ErrorAction SilentlyContinue ) {
Write-Log @PSBoundParameters
if ( Get-Command -Name Write-Log -ErrorAction SilentlyContinue ) {
# SVSMSP modules Write-Log is available
Write-Log -Message $Message -Level $Level -TaskCategory $TaskCategory -LogToEvent:$LogToEvent
}
else {
Write-LogHelper @PSBoundParameters
# fall back to your helper
Write-LogHelper -Message $Message -Level $Level -TaskCategory $TaskCategory -LogToEvent:$LogToEvent
}
}
#endregion
# ─────────────────────────────────────────────────────────────────────────