@@ -1758,7 +1758,7 @@ Function Get-LTError{
1758
1758
Open the log file in a sortable searchable window.
1759
1759
1760
1760
. NOTES
1761
- Version: 1.2
1761
+ Version: 1.3
1762
1762
Author: Chris Taylor
1763
1763
Website: labtechconsulting.com
1764
1764
Creation Date: 3/14/2016
@@ -1770,20 +1770,25 @@ Function Get-LTError{
1770
1770
Update Date: 3/18/2018
1771
1771
Purpose/Change: Changed Erroraction from Stop to unspecified to allow caller to set the ErrorAction.
1772
1772
1773
+ Update Date: 1/26/2019
1774
+ Purpose/Change: Update for better international date parsing support
1775
+
1773
1776
. LINK
1774
1777
http://labtechconsulting.com
1775
1778
#>
1776
1779
[CmdletBinding ()]
1777
1780
Param ()
1778
1781
1779
1782
Begin {
1783
+ Set-Alias - name LINENUM - value Get-CurrentLineNumber - WhatIf:$False - Confirm:$False
1784
+ Write-Debug " Starting $ ( $myInvocation.InvocationName ) at line $ ( LINENUM) "
1780
1785
$BasePath = $ (Get-LTServiceInfo - EA 0 - Verbose:$False - WhatIf:$False - Confirm:$False - Debug:$False | Select-Object - Expand BasePath - EA 0 )
1781
1786
if (! $BasePath ){$BasePath = " $env: windir \LTSVC" }
1782
1787
}# End Begin
1783
1788
1784
1789
Process {
1785
1790
if ($ (Test-Path - Path " $BasePath \LTErrors.txt" ) -eq $False ) {
1786
- Write-Error " ERROR: Unable to find log. $ ( $Error [0 ]) "
1791
+ Write-Error " ERROR: Line $ ( LINENUM ) : Unable to find log. $ ( $Error [0 ]) "
1787
1792
return
1788
1793
}
1789
1794
Try {
@@ -1794,7 +1799,7 @@ Function Get-LTError{
1794
1799
if ($items [1 ]){
1795
1800
$object = New-Object - TypeName PSObject
1796
1801
$object | Add-Member - MemberType NoteProperty - Name ServiceVersion - Value $items [0 ]
1797
- $object | Add-Member - MemberType NoteProperty - Name Timestamp - Value $ ([datetime ]$items [1 ])
1802
+ $object | Add-Member - MemberType NoteProperty - Name Timestamp - Value $ (Try { [datetime ]::Parse( $items [1 ])} Catch {} )
1798
1803
$object | Add-Member - MemberType NoteProperty - Name Message - Value $items [2 ]
1799
1804
Write-Output $object
1800
1805
}
@@ -1803,14 +1808,15 @@ Function Get-LTError{
1803
1808
}# End Try
1804
1809
1805
1810
Catch {
1806
- Write-Error " ERROR: There was an error reading the log. $ ( $Error [0 ]) "
1811
+ Write-Error " ERROR: Line $ ( LINENUM ) : There was an error reading the log. $ ( $Error [0 ]) "
1807
1812
}# End Catch
1808
1813
}# End Process
1809
1814
1810
1815
End {
1811
1816
if ($? ){
1812
1817
}
1813
1818
Else {$Error [0 ]}
1819
+ Write-Debug " Exiting $ ( $myInvocation.InvocationName ) at line $ ( LINENUM) "
1814
1820
}# End End
1815
1821
}# End Function Get-LTError
1816
1822
@@ -2478,7 +2484,7 @@ Function Get-LTProbeErrors{
2478
2484
Open the log file in a sortable searchable window.
2479
2485
2480
2486
. NOTES
2481
- Version: 1.1
2487
+ Version: 1.3
2482
2488
Author: Chris Taylor
2483
2489
Website: labtechconsulting.com
2484
2490
Creation Date: 3/14/2016
@@ -2490,39 +2496,50 @@ Function Get-LTProbeErrors{
2490
2496
Update Date: 3/18/2018
2491
2497
Purpose/Change: Changed Erroraction from Stop to unspecified to allow caller to set the ErrorAction.
2492
2498
2499
+ Update Date: 1/26/2019
2500
+ Purpose/Change: Update for better international date parsing support
2501
+
2493
2502
. LINK
2494
2503
http://labtechconsulting.com
2495
2504
#>
2496
2505
[CmdletBinding ()]
2497
2506
Param ()
2498
2507
2499
2508
Begin {
2509
+ Set-Alias - name LINENUM - value Get-CurrentLineNumber - WhatIf:$False - Confirm:$False
2510
+ Write-Debug " Starting $ ( $myInvocation.InvocationName ) at line $ ( LINENUM) "
2500
2511
$BasePath = $ (Get-LTServiceInfo - EA 0 - Verbose:$False - WhatIf:$False - Confirm:$False - Debug:$False | Select-Object - Expand BasePath - EA 0 )
2501
2512
if (! ($BasePath )){$BasePath = " $env: windir \LTSVC" }
2502
2513
}# End Begin
2503
2514
2504
2515
Process {
2505
2516
if ($ (Test-Path - Path " $BasePath \LTProbeErrors.txt" ) -eq $False ) {
2506
- Write-Error " ERROR: Unable to find log. $ ( $Error [0 ]) "
2517
+ Write-Error " ERROR: Line $ ( LINENUM ) : Unable to find log. $ ( $Error [0 ]) "
2507
2518
return
2508
2519
}
2509
2520
$errors = Get-Content " $BasePath \LTProbeErrors.txt"
2510
2521
$errors = $errors -join ' ' -split ' :::'
2511
- Foreach ($Line in $Errors ){
2512
- $items = $Line -split " `t " -replace ' - ' , ' '
2513
- $object = New-Object - TypeName PSObject
2514
- $object | Add-Member - MemberType NoteProperty - Name ServiceVersion - Value $items [0 ]
2515
- $object | Add-Member - MemberType NoteProperty - Name Timestamp - Value $ ([datetime ]$items [1 ])
2516
- $object | Add-Member - MemberType NoteProperty - Name Message - Value $items [2 ]
2517
- Write-Output $object
2518
- }# End Foreach
2522
+ Try {
2523
+ Foreach ($Line in $Errors ){
2524
+ $items = $Line -split " `t " -replace ' - ' , ' '
2525
+ $object = New-Object - TypeName PSObject
2526
+ $object | Add-Member - MemberType NoteProperty - Name ServiceVersion - Value $items [0 ]
2527
+ $object | Add-Member - MemberType NoteProperty - Name Timestamp - Value $ (Try {[datetime ]::Parse($items [1 ])} Catch {})
2528
+ $object | Add-Member - MemberType NoteProperty - Name Message - Value $items [2 ]
2529
+ Write-Output $object
2530
+ }# End Foreach
2531
+ }# End Try
2532
+
2533
+ Catch {
2534
+ Write-Error " ERROR: Line $ ( LINENUM) : There was an error reading the log. $ ( $Error [0 ]) "
2535
+ }# End Catch
2519
2536
}
2520
2537
2521
2538
End {
2522
2539
if ($? ){
2523
2540
}
2524
2541
Else {$Error [0 ]}
2525
-
2542
+ Write-Debug " Exiting $ ( $myInvocation .InvocationName ) at line $ ( LINENUM ) "
2526
2543
}# End End
2527
2544
}# End Function Get-LTProbeErrors
2528
2545
0 commit comments