From a77b048b873a6c514a09a039109f0a8f441e87a7 Mon Sep 17 00:00:00 2001 From: Zachary Gorman Date: Mon, 1 Jul 2024 10:32:55 -0700 Subject: [PATCH] Updated PCMonitor PCMonitor now prompts for a waiting interval, gives user the option to be notified, displays a propress bar when initializing sessions, and updates a datetime so user knows script isn't hanging --- Private/PCMonitor.ps1 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Private/PCMonitor.ps1 b/Private/PCMonitor.ps1 index f7cbcd2..d16adf2 100644 --- a/Private/PCMonitor.ps1 +++ b/Private/PCMonitor.ps1 @@ -12,20 +12,29 @@ function Invoke-PCMonitor { $dogs = @() # Initialize computer sessions foreach ($comp in $comps) { + Write-Progress -Activity "Initializing sessions" -Status $comp -PercentComplete ($dogs.Length/$comps.Length) $dog = [WatchDog]::new($comp) $null = $dog.Update() $dogs += $dog } + Write-Progress -Activity "Initializing sessions" -Completed while ($true) { + $change = $false foreach ($dog in $dogs) { $msg = $dog.ReportChange() if ($msg) { + $change = $true if ($notify) { $null = [System.Windows.MessageBox]::Show($msg) } Write-Host "$msg" } } + # Update date and time so user knows script hasn't frozen + if (-not ($change)) { + $date = Get-Date -Format "[MM/dd/yy HH:mm:ss]" + Write-Host -NoNewline "$date `r" + } Start-Sleep $sleepTime } }