2021-08-26 10:46:12 +02:00
|
|
|
|
<#
|
2021-07-13 19:03:30 +02:00
|
|
|
|
.SYNOPSIS
|
|
|
|
|
add-memo.ps1 [<text>]
|
|
|
|
|
.DESCRIPTION
|
2021-08-29 17:50:03 +02:00
|
|
|
|
Adds the given memo text to $HOME/Memos.csv.
|
2021-07-13 19:03:30 +02:00
|
|
|
|
.EXAMPLE
|
|
|
|
|
PS> .\add-memo.ps1 "Buy apples"
|
|
|
|
|
.LINK
|
|
|
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
|
.NOTES
|
2021-08-29 17:50:03 +02:00
|
|
|
|
Author: Markus Fleschutz · License: CC0
|
2020-12-29 15:14:21 +01:00
|
|
|
|
#>
|
2020-12-24 10:29:13 +01:00
|
|
|
|
|
2021-08-24 20:46:03 +02:00
|
|
|
|
param([string]$text = "")
|
2020-12-24 10:29:13 +01:00
|
|
|
|
|
|
|
|
|
try {
|
2021-08-24 20:46:03 +02:00
|
|
|
|
if ($text -eq "" ) { $text = read-host "Enter the memo text to add" }
|
|
|
|
|
|
2021-05-04 16:31:15 +02:00
|
|
|
|
$Path = "$HOME/Memos.csv"
|
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)
|
2021-08-24 20:46:03 +02:00
|
|
|
|
$Line = "$Time,$User,$text"
|
2020-12-24 10:29:13 +01:00
|
|
|
|
|
2021-06-07 08:48:17 +02:00
|
|
|
|
if (-not(test-path "$Path" -pathType leaf)) {
|
2021-08-24 20:46:03 +02:00
|
|
|
|
write-output "Time,User,text" > "$Path"
|
2021-05-04 16:41:47 +02:00
|
|
|
|
}
|
2021-05-04 16:31:15 +02:00
|
|
|
|
write-output $Line >> "$Path"
|
|
|
|
|
|
|
|
|
|
"✔️ added to 📄$Path"
|
2020-12-24 10:29:13 +01:00
|
|
|
|
exit 0
|
|
|
|
|
} catch {
|
2021-05-02 21:30:48 +02:00
|
|
|
|
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
2020-12-24 10:29:13 +01:00
|
|
|
|
exit 1
|
|
|
|
|
}
|