Skip to content

Instantly share code, notes, and snippets.

@mattbalzan
Last active June 25, 2026 11:15
Show Gist options
  • Select an option

  • Save mattbalzan/26a8fc2302c9a6ab730de30abc62dc11 to your computer and use it in GitHub Desktop.

Select an option

Save mattbalzan/26a8fc2302c9a6ab730de30abc62dc11 to your computer and use it in GitHub Desktop.
Simple Log Function
# LOG FUNCTION
# Matt Balzan | https://mattbalzan.github.io/My-Site
# CONFIGURATION
$customer = "mattGPT"
$feature = "Stuff"
$logFolder = "C:\ProgramData\$customer\$feature"
if (-not (Test-Path $logFolder)) { New-Item -Path $logFolder -ItemType Directory -Force | Out-Null }
$logFile = Join-Path $logFolder "$($feature).log"
# FUNCTION LOG
function Log($m) {
$entry = "$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') | $m"
$entry | Out-File -FilePath $logFile -Append -Encoding utf8
Write-Host $entry
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment