Skip to content

Instantly share code, notes, and snippets.

@aflyen
Created March 18, 2020 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aflyen/914d741d49d29f3ca62182a2a31d3547 to your computer and use it in GitHub Desktop.
Save aflyen/914d741d49d29f3ca62182a2a31d3547 to your computer and use it in GitHub Desktop.
# 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