-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathonair-client.ps1
52 lines (49 loc) · 1.46 KB
/
onair-client.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Stark's Onair Windows Powershell Client Script
#
# todo: tray icon, start on boot, logging
$global:ErrorActionPreference= 'SilentlyContinue'
$global:ProgressPreference = 'SilentlyContinue'
$url = "onair.starkenburg.com"
$user = "Mike"
$seconds = 2
$laststate = "openIdle"
Do
{
If (Get-Process Zoom)
{
# Zoom is active and there are ZERO UDP packets
If ((Get-NetUDPEndpoint -OwningProcess (Get-Process Zoom).Id -EA 0|Measure-Object).count -lt 1)
{
Write-Host "zoom is open but no meeting"
If ($laststate -ne "openIdle")
{
Invoke-WebRequest -UseBasicParsing -Uri $url/?LED=OFF | Out-Null
Write-Host "Setting LED OFF"
$laststate = "openIdle"
}
}
# Zoom is active and there are UDP packets
If ((Get-NetUDPEndpoint -OwningProcess (Get-Process Zoom).Id -EA 0|Measure-Object).count -gt 0)
{
Write-Host $user "is in a meeting"
If ($laststate -ne "inMeeting")
{
Invoke-WebRequest -UseBasicParsing -Uri $url/?LED=BLUE | Out-Null
Write-Host "Setting LED BLUE"
$laststate = "inMeeting"
}
}
}
else
{
Write-host "there is no zoom process"
If ($laststate -ne "noProcess")
{
Invoke-WebRequest -UseBasicParsing -Uri $url/?LED=OFF | Out-Null
Write-Host "Setting LED OFF"
$laststate = "noProcess"
}
}
Start-Sleep $seconds
}
while ($true)