fixed the write-loghybrid function?

This commit is contained in:
2025-06-29 00:38:47 -04:00
parent b0912a68f5
commit d0a703539a

View File

@@ -220,11 +220,23 @@ function Write-LogHelper {
} }
} }
# Hybrid wrapper: uses your module's Write-Log if available, else falls back function Write-LogHybrid {
[CmdletBinding()]
param(
[Parameter(Mandatory)][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 ) { if ( Get-Command Write-Log -ErrorAction SilentlyContinue ) {
function Write-LogHybrid { param($Message,$Level,$TaskCategory,$LogToEvent) Write-Log @PSBoundParameters } Write-Log @PSBoundParameters
} else { }
function Write-LogHybrid { param($Message,$Level,$TaskCategory,$LogToEvent) Write-LogHelper @PSBoundParameters } else {
Write-LogHelper @PSBoundParameters
}
} }
#endregion #endregion