function LogMe() {
Param(
[parameter(Mandatory = $true, ValueFromPipeline = $true)]$logEntry,
[switch]$display,
[switch]$error,
[switch]$warning,
[switch]$progress
)
if ($error) {
$logEntry = "[ERROR] $logEntry"
Write-Host "$logEntry" -ForegroundColor Red
} elseif ($warning) {
Write-Warning "$logEntry"
$logEntry = "[WARNING] $logEntry"
} elseif ($progress) {
Write-Host "$logEntry" -ForegroundColor Green
} elseif ($display) {
Write-Host "$logEntry"
}
#$logEntry = ((Get-Date -uformat "%D %T") + " - " + $logEntry)
$logEntry | -force Out-File $logFile -Append
}
上面的代码吐出了标题中描述的错误。我尝试了-force
任何其他建议吗?
这不是C#本身,但是当我使用pipeline.invoke
运行时,我得到的错误来自C#。