diff --git a/README.md b/README.md index 52b865c5..9ba305d2 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ The following PowerShell scripts can be found in the [Scripts/](Scripts/) subfol * [list-anagrams.ps1](Scripts/list-anagrams.ps1) - lists all anagrams of the given word * [list-empty-dirs.ps1](Scripts/list-empty-dirs.ps1) - lists empty subfolders in a directory tree * [list-files.ps1](Scripts/list-files.ps1) - lists all files in the given folder and also in every subfolder +* [list-logbook.ps1](Scripts/list-logbook.ps1) - lists the content of the logbook * [list-unused-files.ps1](Scripts/list-unused-files.ps1) - lists unused files in a directory tree * [list-cmdlets.ps1](Scripts/list-cmdlets.ps1) - lists the PowerShell cmdlets * [list-earthquakes.ps1](Scripts/list-earthquakes.ps1) - lists earthquakes >= 6.0 for the last 30 days @@ -68,7 +69,7 @@ The following PowerShell scripts can be found in the [Scripts/](Scripts/) subfol * [write-blue.ps1](Scripts/write-blue.ps1) - writes the given text in a blue foreground color * [write-braille.ps1](Scripts/write-braille.ps1) - writes the given text in Braille * [write-green.ps1](Scripts/write-green.ps1) - writes the given text in a green foreground color -* [write-logbook.ps1](Scripts/write-logbook.ps1) - writes the given text to Data/Logbook.csv +* [write-logbook.ps1](Scripts/write-logbook.ps1) - writes the given text to the logbook * [write-morse-code.ps1](Scripts/write-morse-code.ps1) - writes the given text in Morse code * [write-motd.ps1](Scripts/write-motd.ps1) - writes the message of the day (MOTD) * [write-red.ps1](Scripts/write-red.ps1) - writes the given text in a red foreground color diff --git a/Scripts/list-logbook.ps1 b/Scripts/list-logbook.ps1 new file mode 100755 index 00000000..95942491 --- /dev/null +++ b/Scripts/list-logbook.ps1 @@ -0,0 +1,28 @@ +#!/snap/bin/powershell + +# Syntax: ./list-logbook.ps1 +# Description: lists the content of the logbook (../Data/Logbook.csv) +# Author: Markus Fleschutz +# Source: github.com/fleschutz/PowerShell +# License: CC0 + +try { + $PathToRepo=(get-item $MyInvocation.MyCommand.Path).directory.parent + + $Table = import-csv "$PathToRepo/Data/Logbook.csv" + + write-output "" + write-output "UTC User Text" + write-output "---------------------------------------------------------------" + foreach($Row in $Table) { + $Time = $Row.UTC + $User = $Row.Username + $Text = $Row.Text + write-output "$Time ($User) $Text" + } + write-output "" + exit 0 +} catch { + write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} diff --git a/Scripts/write-logbook.ps1 b/Scripts/write-logbook.ps1 index 6c418e76..8964bff5 100755 --- a/Scripts/write-logbook.ps1 +++ b/Scripts/write-logbook.ps1 @@ -1,7 +1,7 @@ #!/snap/bin/powershell # Syntax: ./write-logbook.ps1 [] -# Description: writes the given text to Data/Logbook.csv +# Description: writes the given text to the logbook (../Data/Logbook.csv) # Author: Markus Fleschutz # Source: github.com/fleschutz/PowerShell # License: CC0