PowerShell/Scripts/write-logbook.ps1

26 lines
686 B
PowerShell
Raw Normal View History

2021-02-09 19:30:45 +01:00
#!/bin/powershell
2020-12-29 15:14:21 +01:00
<#
.SYNTAX ./write-logbook.ps1 [<text>]
2020-12-29 15:48:24 +01:00
.DESCRIPTION writes the given text to 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:29:13 +01:00
2020-12-29 15:14:21 +01:00
param([string]$Text = "")
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)
2020-12-24 10:29:13 +01:00
if ($Text -eq "" ) {
2020-12-29 15:14:21 +01:00
[string]$Text = read-host "Enter text to write"
2020-12-24 10:29:13 +01:00
}
2020-12-25 11:57:09 +01:00
$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 {
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}