mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-09 13:04:59 +02:00
Update add-memo.ps1, list-memos.ps1, and list-scripts.ps1
This commit is contained in:
@ -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])"
|
||||
|
Reference in New Issue
Block a user