update activitystats.ps1 to have better statuses

This commit is contained in:
zebra 2024-02-28 18:38:00 -08:00
parent 5f3f90b8e3
commit e01ad4fcba

12
activitystats.ps1 Normal file → Executable file
View File

@ -47,9 +47,9 @@ $windowsEdition = (Get-CimInstance Win32_OperatingSystem).Caption
$idleTime = [UserInput]::GetIdleTime() $idleTime = [UserInput]::GetIdleTime()
if ($idleTime.TotalMinutes -gt 15) { if ($idleTime.TotalMinutes -gt 15) {
$lastActive = (Get-Date).add(-$idleTime) $lastActive = (Get-Date).add(-$idleTime)
Write-Host "($username) is logged in via Console and inactive since $lastActive." Write-Host "($username) [console] logged in and inactive since $lastActive."
} else { } else {
Write-Host "($username) is currently logged in via Console and active." Write-Host "($username) [console] is logged in and active."
} }
} elseif ($rdpSession) { } elseif ($rdpSession) {
$username = ($rdpSession -split "\s+")[2] $username = ($rdpSession -split "\s+")[2]
@ -57,9 +57,9 @@ $windowsEdition = (Get-CimInstance Win32_OperatingSystem).Caption
$idleTime = [UserInput]::GetIdleTime() $idleTime = [UserInput]::GetIdleTime()
if ($idleTime.TotalMinutes -gt 15) { if ($idleTime.TotalMinutes -gt 15) {
$lastActive = (Get-Date).add(-$idleTime) $lastActive = (Get-Date).add(-$idleTime)
Write-Host "($username) is logged in via RDP and inactive since $lastActive." Write-Host "($username) [mstsc] logged in and inactive since $lastActive."
} else { } else {
Write-Host "($username) is currently logged in via RDP and active." Write-Host "($username) [mstsc] currently logged in and active."
} }
} }
@ -77,9 +77,9 @@ $windowsEdition = (Get-CimInstance Win32_OperatingSystem).Caption
$idleTime = [UserInput]::GetIdleTime() $idleTime = [UserInput]::GetIdleTime()
if ($idleTime.TotalMinutes -gt 15) { if ($idleTime.TotalMinutes -gt 15) {
$lastActive = (Get-Date).add(-$idleTime) $lastActive = (Get-Date).add(-$idleTime)
Write-Host "($username) is logged in and inactive since $lastActive" Write-Host "($username) [console] logged in and inactive since $lastActive"
} else { } else {
Write-Host "($username) is currently logged on and active." Write-Host "($username) [console] currently logged on and active."
} }
} else { } else {
Write-Host "No user is currently logged on." Write-Host "No user is currently logged on."