@@ -140,6 +140,7 @@ Function Log-Start{
140140 Author: Chris Taylor
141141 Creation Date: 7/17/2015
142142 Purpose/Change: Added directory creation if not present.
143+ Added Append option
143144
144145
145146 . EXAMPLE
@@ -331,6 +332,8 @@ Function Log-Finish{
331332 Creation Date: 01/08/12
332333 Purpose/Change: Added option to not exit calling script if required (via optional parameter)
333334
335+
336+
334337 . EXAMPLE
335338 Log-Finish -LogPath "C:\Windows\Temp\Test_Script.log"
336339
@@ -340,7 +343,7 @@ Function Log-Finish{
340343
341344 [CmdletBinding ()]
342345
343- Param ([Parameter (Mandatory = $true )][string ]$LogPath , [Parameter (Mandatory = $false )][string ]$NoExit )
346+ Param ([Parameter (Mandatory = $true )][string ]$LogPath , [Parameter (Mandatory = $false )][string ]$NoExit , [ Parameter ( Mandatory = $false )][ int ] $Limit )
344347
345348 Process {
346349 Add-Content - Path $LogPath - Value " "
@@ -354,6 +357,10 @@ Function Log-Finish{
354357 Write-Debug " Finished processing at [$ ( [DateTime ]::Now) ]."
355358 Write-Debug " ***************************************************************************************************"
356359
360+ if ($Limit ){
361+ # Limit Log file to 50000 lines
362+ (Get-Content $LogPath - tail $Limit - readcount 0 ) | Set-Content $LogPath - Force - Encoding Unicode
363+ }
357364 # Exit calling script if NoExit has not been specified or is set to False
358365 If (! ($NoExit ) -or ($NoExit -eq $False )){
359366 Exit
@@ -658,7 +665,7 @@ Function Export-LTScript {
658665 try {
659666 # Create log
660667 if ((Test-Path $Config.Settings.LogPath ) -eq $false ){New-Item - ItemType Directory - Force - Path $Config.Settings.LogPath | Out-Null }
661- Log- Start - LogPath $LogPath - LogName $LogName - ScriptVersion $ScriptVersion
668+ Log- Start - LogPath $LogPath - LogName $LogName - ScriptVersion $ScriptVersion - Append
662669
663670 # Check backup directory
664671 if ((Test-Path $BackupRoot ) -eq $false ){New-Item - ItemType Directory - Force - Path $BackupRoot | Out-Null }
0 commit comments