Skip to content

Commit

Permalink
Export Script
Browse files Browse the repository at this point in the history
Error capture was going crazy. Added log trimming
  • Loading branch information
LabtechConsulting committed Oct 6, 2015
1 parent 7e52cfa commit a09fd7d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions LT-ScriptExport.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
Catch {
$ErrorMessage = $_.Exception.Message
$FailedItem = $_.Exception.ItemName
Log-Error -LogPath $FullLogPath -ErrorDesc "Error durring config creation: $FailedItem, $ErrorMessage `n$Error[0]" -ExitGracefully $True
Log-Error -LogPath $FullLogPath -ErrorDesc "Error durring config creation: $FailedItem, $ErrorMessage" -ExitGracefully $True
}
}
Else {
Expand Down Expand Up @@ -367,7 +367,7 @@ Function Log-Finish{
Write-Debug "***************************************************************************************************"

if ($Limit){
#Limit Log file to 50000 lines
#Limit Log file to XX lines
(Get-Content $FullLogPath -tail $Limit -readcount 0) | Set-Content $FullLogPath -Force -Encoding Unicode
}
#Exit calling script if NoExit has not been specified or is set to False
Expand Down Expand Up @@ -572,7 +572,7 @@ Function Export-LTScript {
Catch {
$ErrorMessage = $_.Exception.Message
$FailedItem = $_.Exception.ItemName
Log-Error -FullLogPath $FullLogPath -ErrorDesc "Unable to remove folder data from XML: $FailedItem, $ErrorMessage `n$Error[0]" -ExitGracefully $True
Log-Error -FullLogPath $FullLogPath -ErrorDesc "Unable to remove folder data from XML: $FailedItem, $ErrorMessage" -ExitGracefully $True
}
}
Else {
Expand All @@ -595,7 +595,7 @@ Function Export-LTScript {
Catch {
$ErrorMessage = $_.Exception.Message
$FailedItem = $_.Exception.ItemName
Log-Error -FullLogPath $FullLogPath -ErrorDesc "Unable to remove folder data from XML: $FailedItem, $ErrorMessage `n$Error[0]" -ExitGracefully $True
Log-Error -FullLogPath $FullLogPath -ErrorDesc "Unable to remove folder data from XML: $FailedItem, $ErrorMessage" -ExitGracefully $True
}
}
Else {
Expand Down Expand Up @@ -631,7 +631,7 @@ Function Export-LTScript {
Catch {
$ErrorMessage = $_.Exception.Message
$FailedItem = $_.Exception.ItemName
Log-Error -FullLogPath $FullLogPath -ErrorDesc "Unable to save script: $FailedItem, $ErrorMessage `n$Error[0]" -ExitGracefully $True
Log-Error -FullLogPath $FullLogPath -ErrorDesc "Unable to save script: $FailedItem, $ErrorMessage" -ExitGracefully $True
}
}
Else {
Expand Down Expand Up @@ -662,7 +662,7 @@ Function Export-LTScript {
Catch {
$ErrorMessage = $_.Exception.Message
$FailedItem = $_.Exception.ItemName
Log-Error -FullLogPath $FullLogPath -ErrorDesc "Unable to save script: $FailedItem, $ErrorMessage `n$Error[0]" -ExitGracefully $True
Log-Error -FullLogPath $FullLogPath -ErrorDesc "Unable to save script: $FailedItem, $ErrorMessage" -ExitGracefully $True
}
}

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

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

Log-Finish -FullLogPath $FullLogPath
Log-Finish -FullLogPath $FullLogPath -Limit 50000

#endregion

0 comments on commit a09fd7d

Please sign in to comment.