Last active
July 9, 2020 08:06
-
-
Save pjxiao/820ee3ed3501aa64e6a243ef18b689c3 to your computer and use it in GitHub Desktop.
Notify if zoom is running on my computer to Slack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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