2023-09-15 14:33:51 +00:00
|
|
|
# Write to Log Function
|
2022-03-14 13:55:02 +00:00
|
|
|
|
2023-09-15 14:38:54 +00:00
|
|
|
function Write-ToLog
|
2023-09-15 14:33:51 +00:00
|
|
|
{
|
|
|
|
# Get log
|
|
|
|
[CmdletBinding()]
|
|
|
|
param
|
|
|
|
(
|
2023-09-15 14:38:54 +00:00
|
|
|
[string]
|
|
|
|
$LogMsg,
|
|
|
|
[string]
|
|
|
|
$LogColor = 'White'
|
2023-09-15 14:33:51 +00:00
|
|
|
)
|
2023-09-15 14:38:54 +00:00
|
|
|
|
2023-09-15 14:33:51 +00:00
|
|
|
$Log = ('{0} - {1}' -f (Get-Date -UFormat '%T'), $LogMsg)
|
2023-09-15 14:38:54 +00:00
|
|
|
|
2023-09-15 14:33:51 +00:00
|
|
|
#Echo log
|
|
|
|
$Log | Write-Host -ForegroundColor $LogColor
|
2023-09-15 14:38:54 +00:00
|
|
|
|
2023-09-15 14:33:51 +00:00
|
|
|
#Write log to file
|
|
|
|
$Log | Out-File -FilePath $LogFile -Append -Force -Confirm:$false
|
2022-10-26 22:49:10 +00:00
|
|
|
}
|