@@ -194,18 +194,19 @@ function Get-CurrentUpgradePhase {
194194 $PrefixRegex = ' (^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}), Info\s+MOUPG\s+' ;
195195 $Regex1 = $PrefixRegex + ' Setup phase change: \[(.+?)\] -> \[(.+?)\]$' ;
196196 $Regex2 = $PrefixRegex + ' SetupManager::DetermineSetupPhase: CurrentSetupPhase \[(.+?)\]$' ;
197-
197+
198198 # Approx 400k lines in total on a clean install.
199199
200200 if (-not (Test-Path $Path )) {
201+ Invoke-Info " Log file not found, assuming upgrade has not started yet." ;
201202 return $null ; # Not started yet.
202203 }
203204
204205 if ($null -eq $Script :LogPhaseReader.ReadHandle ) {
205206 $Script :LogPhaseReader.ReadHandle = [System.IO.StreamReader ]::new($Path );
206207 }
207208
208- for ($i = $ Script :LogPhaseReader.LinesRead ; $i -lt $LogPhaseReader .Handle.BaseStream.Length ) {
209+ while ($Script :LogPhaseReader.ReadHandle.Peek () -ne -1 ) {
209210 $Line = $Script :LogPhaseReader.ReadHandle.ReadLine ();
210211 $Script :LogPhaseReader.LinesRead ++ ;
211212
@@ -216,8 +217,8 @@ function Get-CurrentUpgradePhase {
216217
217218 if ($Line -match $Regex1 ) {
218219 $Time = [DateTime ]::ParseExact($matches [1 ], " yyyy-MM-dd HH:mm:ss" , $null );
219- $OldPhase = $matches [1 ];
220- $NewPhase = $matches [2 ];
220+ $OldPhase = $matches [2 ];
221+ $NewPhase = $matches [3 ];
221222
222223 if ($NewPhase -ne $Script :LogPhaseReader.LastKnownPhase ) {
223224 Invoke-Info " Setup phase changed from $OldPhase to $NewPhase at $Time " ;
0 commit comments