https://github.com/PowerShellCrack/YetAnotherCMLoggerPSModule
Another module that writes a log in cmtrace format but with an output
https://github.com/PowerShellCrack/YetAnotherCMLoggerPSModule
Last synced: 4 months ago
JSON representation
Another module that writes a log in cmtrace format but with an output
- Host: GitHub
- URL: https://github.com/PowerShellCrack/YetAnotherCMLoggerPSModule
- Owner: PowerShellCrack
- Created: 2022-06-05T17:22:41.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-06-08T15:28:24.000Z (almost 3 years ago)
- Last Synced: 2024-02-04T21:41:01.323Z (about 1 year ago)
- Language: PowerShell
- Size: 9.77 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - PowerShellCrack/YetAnotherCMLoggerPSModule - Another module that writes a log in cmtrace format but with an output (PowerShell)
README
# YetAnotherCMLogger PowerShell module
Another module that writes a log in cmtrace format but with an output
## Prerequisites
No prerequisites are need, however having the cmtrace.exe is useful to read log output
## Cmdlets
- **Get-YaCMLogFileName** --> Grabs current log file
- **Set-YaCMLogFileName** --> Sets a log file (defaults to name of script calling the cmdlet)
- **Restore-YaCMLogFileName** --> restores to original log name and path
- **Write-YaCMLogEntry** --> Write a log entry in CMtrace compatible format## Install
```powershell
Install-Module YetAnotherCMLogger -Force
Import-Module YetAnotherCMLogger
```## Examples
```powershell
#build global log fullpath
$Global:LogFilePath = "$env:Windir\Logs\Mylogfile_$(Get-Date -Format 'yyyy-MM-dd').log"
#or set path by just calling (this will use the name)
Set-YaCMLogFileName
Write-YaCMLogEntry -Message 'this is a new message' -Severity 1 -PassthruFunction Test-output{
${CmdletName} = $MyInvocation.InvocationName
Write-YaCMLogEntry -Message ('this is a new message from [{0}]' -f $MyInvocation.InvocationName) -Source ${CmdletName} -Severity 0 -Passthru
}
Test-output#Create entry in log with warning message and output to host in yellow
Write-YaCMLogEntry -Message 'this is a log entry from an warning' -Severity 2 -Passthru#Create entry in log with error and output to host in red
Write-YaCMLogEntry -Message 'this is a log entry from an error' -Severity 3 -Passthru#restore path (eg. c:\windows\logs\YetAnotherCMLogger_2022-06-05_T02-01-47-PM.log)
Restore-YaCMLogFileName
Write-YaCMLogEntry -Message 'this is a log entry from success' -Severity 1 -Passthru#Set path to c:\ with no appendix to log. (eg. c:\Logs\MyPoshScript.log).
Set-YaCMLogFileName -ParentPath c:\Logs -CallerName 'MyPoshScript' -Appendix ''#Retrieve current log path
Get-YaCMLogFileName```