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:
parent
2b0c9ed93c
commit
a77b048b87
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue