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