I have a PowerShell script to upgrade our Windows 10 computers to newer feature updates. The script also logs certain steps as they progress so we can track them. However, the actual upgrade step takes a couple of hours and (currently) there's no visibility on how far along it is until it's finished. Here's what I have so far:
Get-Content -Path "C:\$WINDOWS.~BT\Sources\Panther\setupact.log" -Tail 0 -Wait | Where {$_ -Match "Mapped\ Global\ progress:\ \[10%]"}
Add-Content -Path "\\SERVER1\Logs\Upgrade.log" -Value "Upgrade stage is at 10% progress"
Get-Content -Path "C:\$WINDOWS.~BT\Sources\Panther\setupact.log" -Tail 0 -Wait | Where {$_ -Match "Mapped\ Global\ progress:\ \[20%]"}
Add-Content -Path "\\SERVER1\Logs\Upgrade.log" -Value "Upgrade stage is at 20% progress"
This works, in so far as Upgrade.log is updated when the script sees the "Mapped Global Progress: 10%" value appear in setupact.log, but the problem is it stops there and will not detect any further updates. I assume this is because of the -wait parameter added to the Get-Content command.
Does anyone know of a way (within PowerShell as I'd prefer not to use an external program) of monitoring the log as described but not experiencing the pause after the first match?
Thanks.