Update add-memo.ps1, list-memos.ps1, and list-scripts.ps1

This commit is contained in:
Markus Fleschutz
2023-04-25 14:17:42 +02:00
parent 60c2008daa
commit bf81138941
4 changed files with 31 additions and 34 deletions

View File

@ -2,12 +2,12 @@
.SYNOPSIS
Adds a memo text
.DESCRIPTION
This PowerShell script adds the given memo text to $HOME/Memos.csv.
This PowerShell script saves the given memo text to Memos.csv in your home folder.
.PARAMETER text
Specifies the text to memorize
.EXAMPLE
PS> ./add-memo "Buy apples"
✔️ added to 📄/home/markus/Memos.csv
✔️ saved to 📄/home/markus/Memos.csv
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -17,19 +17,18 @@
param([string]$text = "")
try {
if ($text -eq "" ) { $text = read-host "Enter the memo text to add" }
if ($text -eq "" ) { $text = Read-Host "Enter the text to memorize" }
$Path = "$HOME/Memos.csv"
$Time = get-date -format "yyyy-MM-ddTHH:mm:ssZ" -asUTC
$User = $(whoami)
$Line = "$Time,$User,$text"
$Path = "~/Memos.csv"
$Time = Get-Date -format FileDateTimeUniversal
$Line = "$Time,$text"
if (-not(test-path "$Path" -pathType leaf)) {
write-output "Time,User,text" > "$Path"
if (-not(Test-Path "$Path" -pathType leaf)) {
Write-Output "TIME,TEXT" > "$Path"
}
write-output $Line >> "$Path"
Write-Output $Line >> "$Path"
"✔️ added to 📄$Path"
"✔️ saved to 📄$Path"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"