Skip to content

Instantly share code, notes, and snippets.

@pjxiao
Last active July 9, 2020 08:06
Show Gist options
  • Save pjxiao/820ee3ed3501aa64e6a243ef18b689c3 to your computer and use it in GitHub Desktop.
Save pjxiao/820ee3ed3501aa64e6a243ef18b689c3 to your computer and use it in GitHub Desktop.
Notify if zoom is running on my computer to Slack
function Monitor-Zoom {
$stat = $fasle
while ($true) {
$cur = $(Get-CimInstance -ClassName Win32_Process -Filter 'name="CptHost.exe"').Length -gt 0
if ($cur -eq $stat) {
# do nothing
}
elseif ($cur -and -not $stat) {
Invoke-WebRequest `
-Method POST `
-Body @{payload="{`"text`": `"テレカン中`"}"} `
'https://hooks.slack.com/services/TXXXXXXXX/BXXXXXXXXXX/****'
}
elseif (-not $cur -and $stat) {
Invoke-WebRequest `
-Method POST `
-Body @{payload="{`"text`": `"テレカン終わり`"}"} `
'https://hooks.slack.com/services/TXXXXXXXX/BXXXXXXXXXX/****'
}
$stat = $cur
Start-Sleep -Seconds 60
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment