mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-22 09:58:19 +02:00
Update add-memo.ps1, list-memos.ps1, and list-scripts.ps1
This commit is contained in:
parent
60c2008daa
commit
bf81138941
@ -1,6 +1,6 @@
|
|||||||
Script,Description
|
SCRIPT,DESCRIPTION
|
||||||
add-firewall-rules.ps1, Adds firewall rules to the given executables (needs admin rights)
|
add-firewall-rules.ps1, Adds firewall rules for executables (needs admin rights)
|
||||||
add-memo.ps1, Adds the given memo text to $HOME/Memos.csv
|
add-memo.ps1, Adds a memo text
|
||||||
build-repo.ps1, Builds a Git repository
|
build-repo.ps1, Builds a Git repository
|
||||||
build-repos.ps1, Builds all Git repositories in a folder
|
build-repos.ps1, Builds all Git repositories in a folder
|
||||||
cd-autostart.ps1, Set the working directory to the user's autostart folder
|
cd-autostart.ps1, Set the working directory to the user's autostart folder
|
||||||
|
|
@ -2,12 +2,12 @@
|
|||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Adds a memo text
|
Adds a memo text
|
||||||
.DESCRIPTION
|
.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
|
.PARAMETER text
|
||||||
Specifies the text to memorize
|
Specifies the text to memorize
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./add-memo "Buy apples"
|
PS> ./add-memo "Buy apples"
|
||||||
✔️ added to 📄/home/markus/Memos.csv
|
✔️ saved to 📄/home/markus/Memos.csv
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -17,19 +17,18 @@
|
|||||||
param([string]$text = "")
|
param([string]$text = "")
|
||||||
|
|
||||||
try {
|
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"
|
$Path = "~/Memos.csv"
|
||||||
$Time = get-date -format "yyyy-MM-ddTHH:mm:ssZ" -asUTC
|
$Time = Get-Date -format FileDateTimeUniversal
|
||||||
$User = $(whoami)
|
$Line = "$Time,$text"
|
||||||
$Line = "$Time,$User,$text"
|
|
||||||
|
|
||||||
if (-not(test-path "$Path" -pathType leaf)) {
|
if (-not(Test-Path "$Path" -pathType leaf)) {
|
||||||
write-output "Time,User,text" > "$Path"
|
Write-Output "TIME,TEXT" > "$Path"
|
||||||
}
|
}
|
||||||
write-output $Line >> "$Path"
|
Write-Output $Line >> "$Path"
|
||||||
|
|
||||||
"✔️ added to 📄$Path"
|
"✔️ saved to 📄$Path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Lists all memos in $HOME/Memos.csv
|
Lists your memo entries
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script lists all memo entries in Memos.csv in the home folder.
|
This PowerShell script lists all memo entries in Memos.csv in your home folder.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./list-memos
|
PS> ./list-memos
|
||||||
.LINK
|
.LINK
|
||||||
@ -13,20 +13,19 @@
|
|||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$Path = "$HOME/Memos.csv"
|
$Path = "~/Memos.csv"
|
||||||
if (test-path "$Path" -pathType leaf) {
|
if (Test-Path "$Path" -pathType leaf) {
|
||||||
write-progress "Reading $Path ..."
|
write-progress "Reading $Path ..."
|
||||||
$Table = import-csv "$Path"
|
$Table = Import-CSV "$Path"
|
||||||
write-progress -completed "Reading $Path"
|
write-progress -completed "Reading $Path"
|
||||||
|
|
||||||
""
|
""
|
||||||
"Time User Text"
|
"Time Text"
|
||||||
"---- ---- ----"
|
"---- ----"
|
||||||
foreach($Row in $Table) {
|
foreach($Row in $Table) {
|
||||||
$Time = $Row.Time
|
$Time = $Row.Time
|
||||||
$User = $Row.User
|
|
||||||
$Text = $Row.Text
|
$Text = $Row.Text
|
||||||
"$Time $User $Text"
|
"$Time $Text"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
"Sorry, no memos saved yet"
|
"Sorry, no memos saved yet"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Lists all PowerShell scripts in this repository
|
Lists all PowerShell scripts
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script lists all PowerShell scripts in the repository (sorted alphabetically).
|
This PowerShell script lists all PowerShell scripts in the repository (sorted alphabetically).
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
@ -12,23 +12,22 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
function ListScripts { param([string]$FilePath)
|
function ListScripts { param([string]$FilePath)
|
||||||
write-progress "Reading $FilePath..."
|
Write-Progress "Reading $FilePath..."
|
||||||
$Table = import-csv "$FilePath"
|
$table = Import-CSV "$FilePath"
|
||||||
foreach($Row in $Table) {
|
[int]$No = 1
|
||||||
|
foreach($row in $table) {
|
||||||
New-Object PSObject -Property @{
|
New-Object PSObject -Property @{
|
||||||
'PowerShell Script' = "$($Row.Script)"
|
'No' = $No++
|
||||||
'Description' = "$($Row.Description)"
|
'Script' = $row.SCRIPT
|
||||||
|
'Description' = $row.DESCRIPTION
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$global:NumScripts = $Table.Count
|
$global:NumScripts = $Table.Count
|
||||||
write-progress -completed "Reading $FilePath..."
|
Write-Progress -completed "."
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$PathToRepo = "$PSScriptRoot/.."
|
ListScripts "$PSScriptRoot/../Data/scripts.csv" | Format-Table -property No,Script,Description
|
||||||
ListScripts "$PathToRepo/Data/scripts.csv" | format-table -property "PowerShell Script",Description
|
|
||||||
|
|
||||||
"✔️ $($global:NumScripts) PowerShell scripts total"
|
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user