mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-06-30 20:50:02 +02:00
Added write-logbook.ps1
This commit is contained in:
26
Scripts/write-logbook.ps1
Executable file
26
Scripts/write-logbook.ps1
Executable file
@ -0,0 +1,26 @@
|
||||
#!/snap/bin/powershell
|
||||
|
||||
# Syntax: ./write-logbook.ps1 [<text>]
|
||||
# Description: writes the given text to Data/Logbook.csv
|
||||
# Author: Markus Fleschutz
|
||||
# Source: github.com/fleschutz/PowerShell
|
||||
# License: CC0
|
||||
|
||||
param([String]$Text)
|
||||
try {
|
||||
if ($Text -eq "" ) {
|
||||
[String]$Text = read-host "Enter text to write"
|
||||
}
|
||||
|
||||
$PathToRepo=(get-item $MyInvocation.MyCommand.Path).directory.parent
|
||||
|
||||
$Timestamp = Get-Date -format "yyyy-MM-dd HH:mm:ss" -AsUTC
|
||||
$UserName = $(whoami)
|
||||
$Line = "$Timestamp,$UserName,$Text"
|
||||
|
||||
write-output $Line >> "$PathToRepo/Data/Logbook.csv"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
Reference in New Issue
Block a user