@@ -1744,21 +1744,21 @@ Function Update-LTService{
1744
1744
}# End End
1745
1745
}# End Function Update-LTService
1746
1746
1747
- Function Get-LTError {
1747
+ Function Get-LTErrors {
1748
1748
<#
1749
1749
. SYNOPSIS
1750
1750
This will pull the %ltsvcdir%\LTErrors.txt file into an object.
1751
1751
1752
1752
. EXAMPLE
1753
- Get-LTError | where {(Get-date $_.Time) -gt (get-date).AddHours(-24)}
1753
+ Get-LTErrors | where {(Get-date $_.Time) -gt (get-date).AddHours(-24)}
1754
1754
Get a list of all errors in the last 24hr
1755
1755
1756
1756
. EXAMPLE
1757
- Get-LTError | Out-Gridview
1757
+ Get-LTErrors | Out-Gridview
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,31 +1770,36 @@ 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. Function rename.
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 lelog. "
1787
1792
return
1788
1793
}
1789
1794
Try {
1790
1795
$errors = Get-Content " $BasePath \LTErrors.txt"
1791
- $errors = $errors -join ' ' -split ' :::'
1796
+ $errors = $errors -join ' ' -split ' ::: '
1792
1797
foreach ($Line in $Errors ){
1793
1798
$items = $Line -split " `t " -replace ' - ' , ' '
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,16 +1808,18 @@ 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
- }# End Function Get-LTError
1821
+ }# End Function Get-LTErrors
1822
+ Set-Alias - Name Get-LTError - Value Get-LTErrors
1816
1823
1817
1824
Function Reset-LTService {
1818
1825
<#
@@ -2478,7 +2485,7 @@ Function Get-LTProbeErrors{
2478
2485
Open the log file in a sortable searchable window.
2479
2486
2480
2487
. NOTES
2481
- Version: 1.1
2488
+ Version: 1.3
2482
2489
Author: Chris Taylor
2483
2490
Website: labtechconsulting.com
2484
2491
Creation Date: 3/14/2016
@@ -2490,39 +2497,50 @@ Function Get-LTProbeErrors{
2490
2497
Update Date: 3/18/2018
2491
2498
Purpose/Change: Changed Erroraction from Stop to unspecified to allow caller to set the ErrorAction.
2492
2499
2500
+ Update Date: 1/26/2019
2501
+ Purpose/Change: Update for better international date parsing support
2502
+
2493
2503
. LINK
2494
2504
http://labtechconsulting.com
2495
2505
#>
2496
2506
[CmdletBinding ()]
2497
2507
Param ()
2498
2508
2499
2509
Begin {
2510
+ Set-Alias - name LINENUM - value Get-CurrentLineNumber - WhatIf:$False - Confirm:$False
2511
+ Write-Debug " Starting $ ( $myInvocation.InvocationName ) at line $ ( LINENUM) "
2500
2512
$BasePath = $ (Get-LTServiceInfo - EA 0 - Verbose:$False - WhatIf:$False - Confirm:$False - Debug:$False | Select-Object - Expand BasePath - EA 0 )
2501
2513
if (! ($BasePath )){$BasePath = " $env: windir \LTSVC" }
2502
2514
}# End Begin
2503
2515
2504
2516
Process {
2505
2517
if ($ (Test-Path - Path " $BasePath \LTProbeErrors.txt" ) -eq $False ) {
2506
- Write-Error " ERROR: Unable to find log. $ ( $Error [ 0 ] ) "
2518
+ Write-Error " ERROR: Line $ ( LINENUM ) : Unable to find log."
2507
2519
return
2508
2520
}
2509
2521
$errors = Get-Content " $BasePath \LTProbeErrors.txt"
2510
- $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
+ $errors = $errors -join ' ' -split ' ::: '
2523
+ Try {
2524
+ Foreach ($Line in $Errors ){
2525
+ $items = $Line -split " `t " -replace ' - ' , ' '
2526
+ $object = New-Object - TypeName PSObject
2527
+ $object | Add-Member - MemberType NoteProperty - Name ServiceVersion - Value $items [0 ]
2528
+ $object | Add-Member - MemberType NoteProperty - Name Timestamp - Value $ (Try {[datetime ]::Parse($items [1 ])} Catch {})
2529
+ $object | Add-Member - MemberType NoteProperty - Name Message - Value $items [2 ]
2530
+ Write-Output $object
2531
+ }# End Foreach
2532
+ }# End Try
2533
+
2534
+ Catch {
2535
+ Write-Error " ERROR: Line $ ( LINENUM) : There was an error reading the log. $ ( $Error [0 ]) "
2536
+ }# End Catch
2519
2537
}
2520
2538
2521
2539
End {
2522
2540
if ($? ){
2523
2541
}
2524
2542
Else {$Error [0 ]}
2525
-
2543
+ Write-Debug " Exiting $ ( $myInvocation .InvocationName ) at line $ ( LINENUM ) "
2526
2544
}# End End
2527
2545
}# End Function Get-LTProbeErrors
2528
2546
@@ -3521,7 +3539,7 @@ Function Initialize-LTServiceModule{
3521
3539
$PublicFunctions = @ (((@"
3522
3540
ConvertFrom-LTSecurity
3523
3541
ConvertTo-LTSecurity
3524
- Get-LTError
3542
+ Get-LTErrors
3525
3543
Get-LTLogging
3526
3544
Get-LTProbeErrors
3527
3545
Get-LTProxy
@@ -3547,6 +3565,7 @@ Update-LTService
3547
3565
"@ ) -replace " [`r`n ,\s]+" , ' ,' ) -split ' ,' )
3548
3566
3549
3567
$PublicAlias = @ (((@"
3568
+ Get-LTError
3550
3569
ReInstall-LTService
3551
3570
"@ ) -replace " [`r`n ,\s]+" , ' ,' ) -split ' ,' )
3552
3571
0 commit comments