2024-05-29 18:57:07 +02:00
|
|
|
|
<#
|
|
|
|
|
.SYNOPSIS
|
|
|
|
|
Remembers a text
|
|
|
|
|
.DESCRIPTION
|
2024-05-29 20:31:08 +02:00
|
|
|
|
This PowerShell script saves the given text to 'Remember.csv' in your home folder.
|
2024-05-29 18:57:07 +02:00
|
|
|
|
.PARAMETER text1
|
|
|
|
|
Specifies the text to memorize
|
|
|
|
|
.EXAMPLE
|
|
|
|
|
PS> ./remember.ps1 "Buy apples"
|
2024-05-29 20:31:08 +02:00
|
|
|
|
✔️ Saved to /home/Markus/Remember.csv in 0s.
|
2024-05-29 18:57:07 +02:00
|
|
|
|
.LINK
|
|
|
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
|
.NOTES
|
|
|
|
|
Author: Markus Fleschutz | License: CC0
|
|
|
|
|
#>
|
|
|
|
|
|
|
|
|
|
param([string]$text1 = "", [string]$text2 = "", [string]$text3 = "")
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
if ($text1 -eq "") { $text1 = Read-Host "Enter what needs to be remembered" }
|
|
|
|
|
|
|
|
|
|
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
2024-05-29 20:31:08 +02:00
|
|
|
|
|
|
|
|
|
[string]$timestampString = Get-Date -UFormat %s
|
|
|
|
|
$timestampString = $timestampString -replace ',','.'
|
|
|
|
|
[int64]$unixTimestamp = $timestampString
|
|
|
|
|
|
|
|
|
|
$path = "~/Remember.csv"
|
2024-05-29 18:57:07 +02:00
|
|
|
|
|
|
|
|
|
if (-not(Test-Path "$path" -pathType leaf)) {
|
2024-05-29 20:31:08 +02:00
|
|
|
|
Write-Output "TIMESTAMP,TEXT" > $path
|
2024-05-29 18:57:07 +02:00
|
|
|
|
}
|
2024-05-29 20:31:08 +02:00
|
|
|
|
Write-Output "$($unixTimestamp),$text1 $text2 $text3" >> $path
|
2024-05-29 18:57:07 +02:00
|
|
|
|
$path = Resolve-Path $path
|
|
|
|
|
|
|
|
|
|
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
|
|
|
|
"✔️ Saved to $path in $($elapsed)s."
|
|
|
|
|
exit 0 # success
|
|
|
|
|
} catch {
|
|
|
|
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
|
|
|
|
exit 1
|
|
|
|
|
}
|