|  | 
| 1 |  | -# Add easy logging to PowerShell! | 
|  | 1 | +# Add easy logging to PowerShell | 
|  | 2 | + | 
| 2 | 3 | ## Installation | 
| 3 |  | -1. download the latest release from [git-releases](https://git.brz.de/powershell-modules/poshlogging/-/releases) | 
|  | 4 | + | 
|  | 5 | +1. download the latest release from [git-releases](https://github.com/tim-krehan/powershell-logging/releases) | 
| 4 | 6 | 2. extract the files | 
| 5 |  | -3. open the PowerShell in the new folder | 
| 6 |  | -4. execute the following command: | 
|  | 7 | +3. Open the Powershell in the extracted Folder | 
|  | 8 | +4. Install the module with the following command: | 
|  | 9 | + | 
| 7 | 10 | ``` powershell | 
| 8 |  | -$source = ".\export\PoShLogging" | 
| 9 |  | -$userModulePath = $env:PSModulePath.split(";") |Where-Object -FilterScript {$_ -like "*$env:USERNAME*Windows*PowerShell*"} | 
| 10 |  | -Copy-Item -Path $source -Destination $userModulePath -Force -Recurse | 
|  | 11 | +Get-Module ".\export\PoShLogging" -ListAvailable |install-module -Scope CurrentUser | 
| 11 | 12 | ``` | 
|  | 13 | + | 
| 12 | 14 | ## Usage | 
| 13 |  | -### Write-Log | 
|  | 15 | + | 
|  | 16 | +### Open-Log | 
|  | 17 | + | 
| 14 | 18 | ``` powershell | 
| 15 |  | -Write-Log INFO "i am a info logline" | 
| 16 |  | -``` | 
|  | 19 | +Open-Log -Name "PowershellLogging" -ShowDebug -LogPath ".\LOG" | 
| 17 | 20 | ``` | 
| 18 |  | -PS> 2020.12.07 11:58:39.677 -    INFO - [email protected] : i am a informational logline | 
|  | 21 | + | 
|  | 22 | +``` txt | 
|  | 23 | +Name         : PowershellLogging | 
|  | 24 | +FullName     : C:\Users\tim-krehan\LOG\PowershellLogging.log | 
|  | 25 | +Folder       : C:\Users\tim-krehan\LOG | 
|  | 26 | +LogLevels    : {DEBUG, INFO, WARNING, SUCCESS...} | 
|  | 27 | +LogLines     : | 
|  | 28 | +WriteThrough : True | 
| 19 | 29 | ``` | 
| 20 |  | -### Get-LogConfig | 
|  | 30 | + | 
|  | 31 | +### Write-Log | 
|  | 32 | + | 
| 21 | 33 | ``` powershell | 
| 22 |  | -Get-LogConfig | 
| 23 |  | -``` | 
|  | 34 | +Write-Log INFO information | 
| 24 | 35 | ``` | 
| 25 |  | -PS> | 
| 26 | 36 | 
 | 
| 27 |  | -LogName    Location | 
| 28 |  | --------    -------- | 
| 29 |  | -powershell C:\Users\Steve\Desktop | 
|  | 37 | +``` txt | 
|  | 38 | +2021-01-18 14:38:05.9539 - [email protected] -    INFO - information | 
| 30 | 39 | ``` | 
| 31 |  | -### Set-LogConfig | 
|  | 40 | + | 
|  | 41 | +### Get-Log | 
|  | 42 | + | 
| 32 | 43 | ``` powershell | 
| 33 |  | -Set-LogConfig -Location "C:\Users\Steve\Desktop" -LogName "powershell" | 
| 34 |  | -``` | 
|  | 44 | +Get-Log |Select-Object -ExpandProperty "LogLines" | 
|  | 45 | +``` | 
|  | 46 | + | 
|  | 47 | +``` txt | 
|  | 48 | +DateTime            User Domain       Severity Message | 
|  | 49 | +--------            ---- ------       -------- -------     | 
|  | 50 | +18.01.2021 14:38:05 b550 baugruppe.de INFO     information | 
|  | 51 | +``` | 
|  | 52 | + | 
|  | 53 | +### Clear-Log | 
|  | 54 | + | 
|  | 55 | +clears the current logfile completly | 
|  | 56 | + | 
|  | 57 | +### Close-Log | 
|  | 58 | + | 
|  | 59 | +disconnects from log (can be opend again with ` Open-Log `) | 
0 commit comments