Skip to content

Instantly share code, notes, and snippets.

@ashdar
Last active June 14, 2025 16:16
Show Gist options
  • Save ashdar/abc1465adf6945f1d5a3a6b12ccc0c7b to your computer and use it in GitHub Desktop.
Save ashdar/abc1465adf6945f1d5a3a6b12ccc0c7b to your computer and use it in GitHub Desktop.

Revisions

  1. ashdar revised this gist Jun 14, 2025. 1 changed file with 0 additions and 5 deletions.
    5 changes: 0 additions & 5 deletions foo.cmd
    Original file line number Diff line number Diff line change
    @@ -1,5 +0,0 @@
    @REM This will work from a .BAT or .CMD file, or from the CMD console.
    @REM It's too slow to be used for regular work but it's OK for debugging and troubleshooting.
    @REM It's mainly about enforcing a standard format to make it easier to parse the log file later.

    PowerShell -noprofile -nologo -command "$LogLevel = 'INFO'; $Message = 'Something notable happened';$OutputTemplate = '{0},{1},{2},{3}'; Add-Content -path .\Simple.log.txt -value ($OutputTemplate -f @((Get-Date).ToString('s'), $LogLevel, $ENV:UserName, $Message) ) "
  2. ashdar revised this gist Jun 14, 2025. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion Write-Simple-Log-Example.cmd
    Original file line number Diff line number Diff line change
    @@ -1 +1,5 @@
    ‎‎​
    @REM This will work from a .BAT or .CMD file, or from the CMD console.
    @REM It's too slow to be used for regular work but it's OK for debugging and troubleshooting.
    @REM It's mainly about enforcing a standard format to make it easier to parse the log file later.

    PowerShell -noprofile -nologo -command "$LogLevel = 'INFO'; $Message = 'Something notable happened';$OutputTemplate = '{0},{1},{2},{3}'; Add-Content -path .\Simple.log.txt -value ($OutputTemplate -f @((Get-Date).ToString('s'), $LogLevel, $ENV:UserName, $Message) ) "
  3. ashdar revised this gist Jun 14, 2025. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions foo.cmd
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    @REM This will work from a .BAT or .CMD file, or from the CMD console.
    @REM It's too slow to be used for regular work but it's OK for debugging and troubleshooting.
    @REM It's mainly about enforcing a standard format to make it easier to parse the log file later.

    PowerShell -noprofile -nologo -command "$LogLevel = 'INFO'; $Message = 'Something notable happened';$OutputTemplate = '{0},{1},{2},{3}'; Add-Content -path .\Simple.log.txt -value ($OutputTemplate -f @((Get-Date).ToString('s'), $LogLevel, $ENV:UserName, $Message) ) "
  4. ashdar renamed this gist Jun 14, 2025. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. ashdar created this gist Jun 14, 2025.
    1 change: 1 addition & 0 deletions foo.cmd
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    ‎‎​