PowerShell/Scripts/write-logbook.ps1

27 lines
682 B
PowerShell
Raw Normal View History

2021-02-09 19:30:45 +01:00
#!/bin/powershell
2020-12-29 15:14:21 +01:00
<#
2021-03-22 20:10:18 +01:00
.SYNTAX ./write-logbook.ps1 [<text>]
.DESCRIPTION writes the given text to the logbook (in ../Data/logbook.csv)
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
2020-12-29 15:14:21 +01:00
#>
2020-12-24 10:29:13 +01:00
2021-02-18 20:17:55 +01:00
param($Text = "")
if ($Text -eq "" ) {
$Text = read-host "Enter the text to write"
}
2020-12-24 10:29:13 +01:00
try {
2020-12-29 15:14:21 +01:00
$Time = get-date -format "yyyy-MM-ddTHH:mm:ssZ" -asUTC
2020-12-25 11:57:09 +01:00
$User = $(whoami)
$Line = "$Time,$User,$Text"
2020-12-24 10:29:13 +01:00
$PathToRepo=(get-item $MyInvocation.MyCommand.Path).directory.parent
2020-12-29 15:48:24 +01:00
write-output $Line >> "$PathToRepo/Data/logbook.csv"
2020-12-24 10:29:13 +01:00
exit 0
} catch {
2021-02-16 10:03:20 +01:00
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
2020-12-24 10:29:13 +01:00
exit 1
}