Created
March 18, 2020 19:25
-
-
Save aflyen/914d741d49d29f3ca62182a2a31d3547 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Log event to file | |
function Add-CorpLog | |
{ | |
param( | |
[Parameter(Mandatory=$true)] | |
[string]$Message | |
) | |
if ($CorpWriteLogToConsole -eq $True) | |
{ | |
Write-Host "$($Message)" | |
} | |
Add-Content -Path "$CurrentPath\$CorpLogFileName" -Value "$(Get-Date -Format ""dd.MM.yy HH:mm:ss""): $($Message)" | |
} | |
# Example of usage | |
$CurrentPath = Split-Path -parent $PSCommandPath | |
$CorpLogFileName = "Custom.log" | |
$CorpWriteLogToConsole = $true | |
Add-CorpLog -Message "Started" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment