Skip to content

Instantly share code, notes, and snippets.

@mattbalzan
Created January 6, 2025 10:55
Show Gist options
  • Save mattbalzan/26a8fc2302c9a6ab730de30abc62dc11 to your computer and use it in GitHub Desktop.
Save mattbalzan/26a8fc2302c9a6ab730de30abc62dc11 to your computer and use it in GitHub Desktop.
Simple Log Function
# --[ Log Function ]
# --[ Matt Balzan | mattGPT.co.uk ]
# --[ Set vars ]
$customer = "mattGPT"
$feature = "Stuff"
$logPath = "C:\ProgramData\$customer\$feature"
$logfile = "$logPath\$feature.log"
if(!(Test-Path $logPath)){ New-Item -Path $logPath -ItemType Directory -Force }
# --[ Create log ]
function Log($message){
"$(Get-Date -Format "dd-MM-yyyy hh:mm:ss") | $message" | Out-File $logfile -Append
Write-Host $message
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment