diff --git a/Windows/Chocolatey/ChocolateyUpgrade.ps1 b/Windows/Chocolatey/ChocolateyUpgrade.ps1 index a460815a11e5681a2a0fc7d0167a353ba307a49d..c46f555ce448045d65ec9186b20ee2968ca91969 100644 --- a/Windows/Chocolatey/ChocolateyUpgrade.ps1 +++ b/Windows/Chocolatey/ChocolateyUpgrade.ps1 @@ -15,7 +15,7 @@ function Remove-OldLogFiles { [string]$scriptName ) # Get all log files for the current script - $logFiles = Get-ChildItem -Path $logPath -Filter "$scriptName_*.log" | Sort-Object LastWriteTime -Descending + $logFiles = Get-ChildItem -Path $logPath -Filter "$scriptName`_*.log" | Sort-Object LastWriteTime -Descending # Check if the number of log files exceeds the maximum allowed if ($logFiles.Count -gt $maxFiles) { @@ -32,16 +32,11 @@ Write-Host "Starting script execution..." <#== Get current date and time ==#> Write-Host "Getting current date and time..." -$currentDateTime = Get-Date -Format "yyyy-MM-dd_HHmm" +$currentDateTime = Get-Date -Format "yyyy-MM-dd_HHmmss" # Determine the name of the currently executing script without the extension $scriptName = [System.IO.Path]::GetFileNameWithoutExtension($MyInvocation.MyCommand.Name) -<#== Start Transcript ==#> -Write-Host "Starting transcript..." -$transcriptPath = "C:\Install Logs\$scriptName`_$currentDateTime.log" -Start-Transcript -Path $transcriptPath - # Define the busy.flag file path $busyFlagPath = "C:\Install Logs\ChocolateyUpgrade_busy.flag" @@ -51,6 +46,11 @@ if (Test-Path $busyFlagPath) { exit } +<#== Start Transcript ==#> +Write-Host "Starting transcript..." +$transcriptPath = "C:\Install Logs\$scriptName`_$currentDateTime.log" +Start-Transcript -Path $transcriptPath + # Create the busy.flag file and write start time and script information $startTime = Get-Date -Format "yyyy-MM-dd HH:mm:ss" $busyFlagContent = "Script: $scriptName`nStart Time: $startTime"