mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-12-25 16:18:55 +01:00
Improved timestamps in logbook
This commit is contained in:
parent
e8e57b8308
commit
cfce41d8bd
@ -1,2 +1,2 @@
|
|||||||
UTC,Username,Text
|
Time,User,Text
|
||||||
2020-12-24 09:24:30,mf,Hello World
|
2020-12-24T09:24:30Z,mf,Hello World
|
||||||
|
|
@ -12,11 +12,11 @@ try {
|
|||||||
$Table = import-csv "$PathToRepo/Data/Logbook.csv"
|
$Table = import-csv "$PathToRepo/Data/Logbook.csv"
|
||||||
|
|
||||||
write-output ""
|
write-output ""
|
||||||
write-output "UTC User Text"
|
write-output "Time User Text"
|
||||||
write-output "---------------------------------------------------------------"
|
write-output "---------------------------------------------------------------"
|
||||||
foreach($Row in $Table) {
|
foreach($Row in $Table) {
|
||||||
$Time = $Row.UTC
|
$Time = $Row.Time
|
||||||
$User = $Row.Username
|
$User = $Row.User
|
||||||
$Text = $Row.Text
|
$Text = $Row.Text
|
||||||
write-output "$Time ($User) $Text"
|
write-output "$Time ($User) $Text"
|
||||||
}
|
}
|
||||||
|
@ -8,16 +8,14 @@
|
|||||||
|
|
||||||
param([String]$Text)
|
param([String]$Text)
|
||||||
try {
|
try {
|
||||||
|
$Time = Get-Date -format "yyyy-MM-ddTHH:mm:ssZ" -AsUTC
|
||||||
|
$User = $(whoami)
|
||||||
if ($Text -eq "" ) {
|
if ($Text -eq "" ) {
|
||||||
[String]$Text = read-host "Enter text to write"
|
[String]$Text = read-host "Enter text to write"
|
||||||
}
|
}
|
||||||
|
$Line = "$Time,$User,$Text"
|
||||||
|
|
||||||
$PathToRepo=(get-item $MyInvocation.MyCommand.Path).directory.parent
|
$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"
|
write-output $Line >> "$PathToRepo/Data/Logbook.csv"
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
|
Loading…
Reference in New Issue
Block a user