Skip to content

Commit a09fd7d

Browse files
Export Script
Error capture was going crazy. Added log trimming
1 parent 7e52cfa commit a09fd7d

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

LT-ScriptExport.ps1

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
Catch {
7171
$ErrorMessage = $_.Exception.Message
7272
$FailedItem = $_.Exception.ItemName
73-
Log-Error -LogPath $FullLogPath -ErrorDesc "Error durring config creation: $FailedItem, $ErrorMessage `n$Error[0]" -ExitGracefully $True
73+
Log-Error -LogPath $FullLogPath -ErrorDesc "Error durring config creation: $FailedItem, $ErrorMessage" -ExitGracefully $True
7474
}
7575
}
7676
Else {
@@ -367,7 +367,7 @@ Function Log-Finish{
367367
Write-Debug "***************************************************************************************************"
368368

369369
if ($Limit){
370-
#Limit Log file to 50000 lines
370+
#Limit Log file to XX lines
371371
(Get-Content $FullLogPath -tail $Limit -readcount 0) | Set-Content $FullLogPath -Force -Encoding Unicode
372372
}
373373
#Exit calling script if NoExit has not been specified or is set to False
@@ -572,7 +572,7 @@ Function Export-LTScript {
572572
Catch {
573573
$ErrorMessage = $_.Exception.Message
574574
$FailedItem = $_.Exception.ItemName
575-
Log-Error -FullLogPath $FullLogPath -ErrorDesc "Unable to remove folder data from XML: $FailedItem, $ErrorMessage `n$Error[0]" -ExitGracefully $True
575+
Log-Error -FullLogPath $FullLogPath -ErrorDesc "Unable to remove folder data from XML: $FailedItem, $ErrorMessage" -ExitGracefully $True
576576
}
577577
}
578578
Else {
@@ -595,7 +595,7 @@ Function Export-LTScript {
595595
Catch {
596596
$ErrorMessage = $_.Exception.Message
597597
$FailedItem = $_.Exception.ItemName
598-
Log-Error -FullLogPath $FullLogPath -ErrorDesc "Unable to remove folder data from XML: $FailedItem, $ErrorMessage `n$Error[0]" -ExitGracefully $True
598+
Log-Error -FullLogPath $FullLogPath -ErrorDesc "Unable to remove folder data from XML: $FailedItem, $ErrorMessage" -ExitGracefully $True
599599
}
600600
}
601601
Else {
@@ -631,7 +631,7 @@ Function Export-LTScript {
631631
Catch {
632632
$ErrorMessage = $_.Exception.Message
633633
$FailedItem = $_.Exception.ItemName
634-
Log-Error -FullLogPath $FullLogPath -ErrorDesc "Unable to save script: $FailedItem, $ErrorMessage `n$Error[0]" -ExitGracefully $True
634+
Log-Error -FullLogPath $FullLogPath -ErrorDesc "Unable to save script: $FailedItem, $ErrorMessage" -ExitGracefully $True
635635
}
636636
}
637637
Else {
@@ -662,7 +662,7 @@ Function Export-LTScript {
662662
Catch {
663663
$ErrorMessage = $_.Exception.Message
664664
$FailedItem = $_.Exception.ItemName
665-
Log-Error -FullLogPath $FullLogPath -ErrorDesc "Unable to save script: $FailedItem, $ErrorMessage `n$Error[0]" -ExitGracefully $True
665+
Log-Error -FullLogPath $FullLogPath -ErrorDesc "Unable to save script: $FailedItem, $ErrorMessage" -ExitGracefully $True
666666
}
667667
}
668668

@@ -681,7 +681,7 @@ Function Export-LTScript {
681681
Catch {
682682
$ErrorMessage = $_.Exception.Message
683683
$FailedItem = $_.Exception.ItemName
684-
Log-Error -FullLogPath $FullLogPath -ErrorDesc "Error durring log/backup directory creation: $FailedItem, $ErrorMessage `n$Error[0]" -ExitGracefully $True
684+
Log-Error -FullLogPath $FullLogPath -ErrorDesc "Error durring log/backup directory creation: $FailedItem, $ErrorMessage" -ExitGracefully $True
685685
}
686686

687687
Log-Write -FullLogPath $FullLogPath -LineValue "Getting list of all scripts."
@@ -718,9 +718,9 @@ Function Export-LTScript {
718718
Catch {
719719
$ErrorMessage = $_.Exception.Message
720720
$FailedItem = $_.Exception.ItemName
721-
Log-Error -FullLogPath $FullLogPath -ErrorDesc "Unable to update config with last export date: $FailedItem, $ErrorMessage `n$Error[0]" -ExitGracefully $True
721+
Log-Error -FullLogPath $FullLogPath -ErrorDesc "Unable to update config with last export date: $FailedItem, $ErrorMessage" -ExitGracefully $True
722722
}
723723

724-
Log-Finish -FullLogPath $FullLogPath
724+
Log-Finish -FullLogPath $FullLogPath -Limit 50000
725725

726726
#endregion

0 commit comments

Comments
 (0)