2024-11-08 12:38:20 +01:00
|
|
|
The *remember.ps1* Script
|
|
|
|
===========================
|
2024-08-15 09:51:46 +02:00
|
|
|
|
|
|
|
This PowerShell script saves the given text to 'Remember.csv' in your home folder.
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
```powershell
|
2024-11-08 12:35:11 +01:00
|
|
|
/home/markus/Repos/PowerShell/scripts/remember.ps1 [[-text1] <String>] [[-text2] <String>] [[-text3] <String>] [<CommonParameters>]
|
2024-08-15 09:51:46 +02:00
|
|
|
|
|
|
|
-text1 <String>
|
|
|
|
Specifies the text to memorize
|
|
|
|
|
|
|
|
Required? false
|
|
|
|
Position? 1
|
|
|
|
Default value
|
|
|
|
Accept pipeline input? false
|
|
|
|
Accept wildcard characters? false
|
|
|
|
|
|
|
|
-text2 <String>
|
|
|
|
|
|
|
|
Required? false
|
|
|
|
Position? 2
|
|
|
|
Default value
|
|
|
|
Accept pipeline input? false
|
|
|
|
Accept wildcard characters? false
|
|
|
|
|
|
|
|
-text3 <String>
|
|
|
|
|
|
|
|
Required? false
|
|
|
|
Position? 3
|
|
|
|
Default value
|
|
|
|
Accept pipeline input? false
|
|
|
|
Accept wildcard characters? false
|
|
|
|
|
|
|
|
[<CommonParameters>]
|
|
|
|
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
|
|
|
|
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
|
|
|
|
```
|
|
|
|
|
|
|
|
Example
|
|
|
|
-------
|
|
|
|
```powershell
|
|
|
|
PS> ./remember.ps1 "Buy apples"
|
2024-11-08 12:35:11 +01:00
|
|
|
✅ Saved to /home/Markus/Remember.csv in 0s.
|
2024-08-15 09:51:46 +02:00
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
Notes
|
|
|
|
-----
|
|
|
|
Author: Markus Fleschutz | License: CC0
|
|
|
|
|
|
|
|
Related Links
|
|
|
|
-------------
|
|
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
|
|
|
|
Script Content
|
|
|
|
--------------
|
|
|
|
```powershell
|
|
|
|
<#
|
|
|
|
.SYNOPSIS
|
|
|
|
Remembers a text
|
|
|
|
.DESCRIPTION
|
|
|
|
This PowerShell script saves the given text to 'Remember.csv' in your home folder.
|
|
|
|
.PARAMETER text1
|
|
|
|
Specifies the text to memorize
|
|
|
|
.EXAMPLE
|
|
|
|
PS> ./remember.ps1 "Buy apples"
|
2024-11-08 12:35:11 +01:00
|
|
|
✅ Saved to /home/Markus/Remember.csv in 0s.
|
2024-08-15 09:51:46 +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()
|
|
|
|
|
|
|
|
[string]$timestampString = Get-Date -UFormat %s
|
|
|
|
$timestampString = $timestampString -replace ',','.'
|
|
|
|
[int64]$unixTimestamp = $timestampString
|
|
|
|
|
|
|
|
$path = "~/Remember.csv"
|
|
|
|
|
|
|
|
if (-not(Test-Path "$path" -pathType leaf)) {
|
|
|
|
Write-Output "TIMESTAMP,TEXT" > $path
|
|
|
|
}
|
|
|
|
Write-Output "$($unixTimestamp),$text1 $text2 $text3" >> $path
|
|
|
|
$path = Resolve-Path $path
|
|
|
|
|
|
|
|
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
2024-11-08 12:35:11 +01:00
|
|
|
"✅ Saved to $path in $($elapsed)s."
|
2024-08-15 09:51:46 +02:00
|
|
|
exit 0 # success
|
|
|
|
} catch {
|
|
|
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2024-11-20 11:52:20 +01:00
|
|
|
*(generated by convert-ps2md.ps1 as of 11/20/2024 11:51:59)*
|