Files/Program Files/WindowsPowerShell/Modules/HyperVLabClient/1.0.0.0/Internal/Write-Log.ps1
$script:setupFolder = 'C:\Setup' $script:logFilePath = Join-Path $script:setupFolder 'log.txt' function Write-Log { param ( [string]$Level, [string]$Message ) $timestamp = [System.DateTime]::Now.TimeOfDay.ToString() # FATAL, ERROR, WARNING, INFO, DEBUG, TRACE if (!$Level) { $Level = "INFO" } $formattedMessage = "$timestamp - $($Level.PadLeft(8)) - $Message" switch ($level) { "FATAL" { Write-Host $formattedMessage -ForegroundColor White -BackgroundColor Red } "ERROR" { Write-Host $formattedMessage -ForegroundColor White -BackgroundColor Red } "WARNING" { Write-Host $formattedMessage -ForegroundColor Yellow } "INFO" { Write-Host $formattedMessage -ForegroundColor White } "DEBUG" { Write-Host $formattedMessage -ForegroundColor Cyan } "TRACE" { Write-Host $formattedMessage -ForegroundColor Gray } default { Write-Host $formattedMessage -ForegroundColor White } } if ($script:logFilePath -and (Test-Path $script:logFilePath)) { Add-content $script:logFilePath -value $formattedMessage } } |