mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-08 09:04:18 +01:00
Added write-logbook.ps1
This commit is contained in:
parent
5fdc3cd114
commit
a966acb972
2
Data/Logbook.csv
Normal file
2
Data/Logbook.csv
Normal file
@ -0,0 +1,2 @@
|
||||
UTC,Username,Text
|
||||
2020-12-24 09:24:30,mf,Hello World
|
|
@ -68,6 +68,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-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
|
||||
|
26
Scripts/write-logbook.ps1
Executable file
26
Scripts/write-logbook.ps1
Executable file
@ -0,0 +1,26 @@
|
||||
#!/snap/bin/powershell
|
||||
|
||||
# Syntax: ./write-logbook.ps1 [<text>]
|
||||
# Description: writes the given text to Data/Logbook.csv
|
||||
# Author: Markus Fleschutz
|
||||
# Source: github.com/fleschutz/PowerShell
|
||||
# License: CC0
|
||||
|
||||
param([String]$Text)
|
||||
try {
|
||||
if ($Text -eq "" ) {
|
||||
[String]$Text = read-host "Enter text to write"
|
||||
}
|
||||
|
||||
$PathToRepo=(get-item $MyInvocation.MyCommand.Path).directory.parent
|
||||
|
||||
$Timestamp = Get-Date -format "yyyy-MM-dd HH:mm:ss" -AsUTC
|
||||
$UserName = $(whoami)
|
||||
$Line = "$Timestamp,$UserName,$Text"
|
||||
|
||||
write-output $Line >> "$PathToRepo/Data/Logbook.csv"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
Loading…
Reference in New Issue
Block a user