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 {
|
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 module’s 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
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────────────────
|
# ─────────────────────────────────────────────────────────────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user