fixed the write-loghybrid function?
This commit is contained in:
@@ -220,11 +220,23 @@ function Write-LogHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Hybrid wrapper: uses your module's Write-Log if available, else falls back
|
function Write-LogHybrid {
|
||||||
if (Get-Command Write-Log -ErrorAction SilentlyContinue) {
|
[CmdletBinding()]
|
||||||
function Write-LogHybrid { param($Message,$Level,$TaskCategory,$LogToEvent) Write-Log @PSBoundParameters }
|
param(
|
||||||
} else {
|
[Parameter(Mandatory)][string]$Message,
|
||||||
function Write-LogHybrid { param($Message,$Level,$TaskCategory,$LogToEvent) Write-LogHelper @PSBoundParameters }
|
[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
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-LogHelper @PSBoundParameters
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user