Files
PublicScripts/HelperFunctions/LogTools.ps1
2024-07-18 13:43:05 -05:00

30 lines
742 B
PowerShell

Function Add-LogEntry {
Param (
[Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()]$Message,
[Parameter(Mandatory = $false)] [ValidateSet('Notify', 'Warning', 'Error')]$As,
[Parameter(Mandatory = $false)] [Switch]$NewLine
)
$Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
Switch ($As) {
"Notify" {
$FGC = "Cyan"
}
"Warning" {
$FGC = "Yellow"
}
"Error" {
$FGC = "Red"
}
Default {
$FGC = "White"
}
}
If ($Newline) {
Write-Host "`n[$Timestamp] $Message" -ForegroundColor $FGC
}
Else {
Write-Host "[$Timestamp] $Message" -ForegroundColor $FGC
}
}