PowerShell/Scripts/list-logbook.ps1

29 lines
806 B
PowerShell
Raw Normal View History

2020-12-24 10:44:10 +01:00
#!/snap/bin/powershell
2020-12-29 15:14:21 +01:00
<#
.SYNTAX ./list-logbook.ps1
2020-12-29 15:48:24 +01:00
.DESCRIPTION lists the content of the logbook (in ../Data/logbook.csv)
2020-12-29 15:14:21 +01:00
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
2020-12-24 10:44:10 +01:00
try {
2020-12-29 15:48:24 +01:00
write-progress "Reading Data/logbook.csv..."
2020-12-24 10:44:10 +01:00
$PathToRepo=(get-item $MyInvocation.MyCommand.Path).directory.parent
2020-12-29 15:48:24 +01:00
$Table = import-csv "$PathToRepo/Data/logbook.csv"
2020-12-24 10:44:10 +01:00
write-output ""
2020-12-25 11:57:09 +01:00
write-output "Time User Text"
2020-12-24 10:44:10 +01:00
write-output "---------------------------------------------------------------"
foreach($Row in $Table) {
2020-12-25 11:57:09 +01:00
$Time = $Row.Time
$User = $Row.User
2020-12-24 10:44:10 +01:00
$Text = $Row.Text
write-output "$Time ($User) $Text"
}
write-output ""
exit 0
} catch {
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}