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
This commit is contained in:
Zachary Gorman 2024-07-01 10:32:55 -07:00
parent 2b0c9ed93c
commit a77b048b87

View file

@ -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
}
}