PowerShell/Scripts/write-logbook.ps1

25 lines
668 B
PowerShell
Raw Normal View History

2020-12-24 10:29:13 +01:00
#!/snap/bin/powershell
# Syntax: ./write-logbook.ps1 [<text>]
2020-12-24 10:44:10 +01:00
# Description: writes the given text to the logbook (../Data/Logbook.csv)
2020-12-24 10:29:13 +01:00
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
param([String]$Text)
try {
2020-12-25 11:57:09 +01:00
$Time = Get-Date -format "yyyy-MM-ddTHH:mm:ssZ" -AsUTC
$User = $(whoami)
2020-12-24 10:29:13 +01:00
if ($Text -eq "" ) {
[String]$Text = read-host "Enter text to write"
}
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
write-output $Line >> "$PathToRepo/Data/Logbook.csv"
exit 0
} catch {
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}