Version 1.4c
This commit is contained in:
@@ -1166,13 +1166,6 @@ function Initialize-EnterpriseLog {
|
||||
|
||||
function Write-EnterpriseLog {
|
||||
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Schreibt Enterprise Log Einträge.
|
||||
#>
|
||||
|
||||
|
||||
param(
|
||||
|
||||
[ValidateSet(
|
||||
@@ -1184,91 +1177,34 @@ function Write-EnterpriseLog {
|
||||
|
||||
[string]$Level = "INFO",
|
||||
|
||||
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
|
||||
[string]$Message
|
||||
|
||||
)
|
||||
|
||||
|
||||
|
||||
if(!$Script:LogFile)
|
||||
if([string]::IsNullOrWhiteSpace($Script:LogFile))
|
||||
{
|
||||
|
||||
Initialize-EnterpriseLog |
|
||||
|
||||
Out-Null
|
||||
|
||||
Initialize-EnterpriseLog | Out-Null
|
||||
}
|
||||
|
||||
|
||||
|
||||
$Entry =
|
||||
|
||||
[PSCustomObject]@{
|
||||
$Time = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
||||
|
||||
|
||||
Time =
|
||||
|
||||
Get-Date
|
||||
|
||||
|
||||
|
||||
Level =
|
||||
|
||||
$Level
|
||||
|
||||
|
||||
|
||||
Computer =
|
||||
|
||||
$env:COMPUTERNAME
|
||||
|
||||
|
||||
|
||||
User =
|
||||
|
||||
$env:USERNAME
|
||||
|
||||
|
||||
|
||||
Message =
|
||||
|
||||
$Line = "{0} [{1}] {2} {3}" -f `
|
||||
$Time,
|
||||
$Level,
|
||||
$env:COMPUTERNAME,
|
||||
$Message
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$Line =
|
||||
|
||||
(
|
||||
$Entry.Time.ToString(
|
||||
"yyyy-MM-dd HH:mm:ss"
|
||||
)
|
||||
) +
|
||||
|
||||
" [" +
|
||||
|
||||
$Entry.Level +
|
||||
|
||||
"] " +
|
||||
|
||||
$Entry.Message
|
||||
|
||||
|
||||
|
||||
Add-Content `
|
||||
|
||||
-Path $Script:LogFile `
|
||||
|
||||
-Value $Line
|
||||
|
||||
|
||||
|
||||
return $Entry
|
||||
return $Line
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user