Update StackMonkey.ps1
This commit is contained in:
@@ -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 module’s 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
|
||||
|
||||
# ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user