Add PC uptime tracking feature

- Database: Add lastboottime column to machines table
- API: Accept lastBootUpTime parameter and store in lastboottime column
- PowerShell: Collect LastBootUpTime from Win32_OperatingSystem
  - Update-PC-Minimal.ps1: Add last boot time collection
  - Update-ShopfloorPCs-Remote.ps1: Add last boot time collection and API posting
- Display: Add Uptime column to displaypcs.asp with color-coded badges
  - > 90 days: red badge
  - > 30 days: yellow badge
  - > 7 days: blue badge
  - <= 7 days: muted text
- Filter: Add "Uptime > X days" filter dropdown (7, 30, 90 days)
- SQL: Production migration script for lastboottime column

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
cproudlock
2025-12-09 09:36:23 -05:00
parent 01d4aae38d
commit cd9058d81e
5 changed files with 125 additions and 11 deletions

View File

@@ -81,11 +81,17 @@ if ($interfaces.Count -gt 0) {
$data.networkInterfaces = ($interfaces | ConvertTo-Json -Compress)
}
# Try to get OS
# Try to get OS and last boot time
try {
$os = Get-CimInstance -ClassName Win32_OperatingSystem -ErrorAction Stop
$data.osVersion = $os.Caption
"OS: $($data.osVersion)" | Tee-Object -FilePath $logFile -Append
# Get last boot time
if ($os.LastBootUpTime) {
$data.lastBootUpTime = $os.LastBootUpTime.ToString("yyyy-MM-dd HH:mm:ss")
"Last Boot: $($data.lastBootUpTime)" | Tee-Object -FilePath $logFile -Append
}
} catch {
"ERROR getting OS: $_" | Tee-Object -FilePath $logFile -Append
}