Skip to content

Instantly share code, notes, and snippets.

@1RedOne
Created July 28, 2020 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1RedOne/d9284559742a832fdb2e7bd190a62da7 to your computer and use it in GitHub Desktop.
Save 1RedOne/d9284559742a832fdb2e7bd190a62da7 to your computer and use it in GitHub Desktop.
A functional script to turn a light on and off when entering and leaving Teams and Skype Meetings
#Companion Code to blog post found on FoxDeploy.com 'DIY On-Air Light for Microsoft Teams'
Add-Type -Path "C:\Program Files (x86)\Microsoft Office 2013\LyncSDK\Assemblies\Desktop\Microsoft.Lync.Model.dll";
$lightOnEventName = "meetingStart"
$lightOffEventName = "meetingStop"
$iftttKey = '<YourKeyGoesHere>'
$sleepInterval = 180
$lyncclient = [Microsoft.Lync.Model.LyncClient]::GetClient()
$LastState = $null
Function meetingStart {
irm https://maker.ifttt.com/trigger/$lightOnEventName/with/key/$iftttKey -method Post
}
Function meetingStop {
irm https://maker.ifttt.com/trigger/$lightOffEventName/with/key/$iftttKey -method Post
}
Function Get-LyncMyAvailabilityState{
$MyContact = $lyncclient.Self.Contact;
$myState = $MyContact.GetContactInformation("Availability")
switch ($myState){
(12500) {$state="Be right back"}
(15500) {$state="Appearing Away"}
(3500) {$state="Available"}
(6500) {$state="Busy"}
(9500) {$state="Do Not Disturb"}
Default {$state = "Other State"}
}
return [psCustomObject]@{MySipAddress=$MyContact.Uri;Availability=$state}
}
while($true){
$date = (Get-Date -Format "HH:mm:ss")
$status = get-LyncMyAvailabilityState
if ($LastState -eq $status.Availability){
"[$date] status not changed from $LastState, light should stay the same..."
start-sleep -Seconds $sleepInterval
Continue
}
if ($status.Availability -in ("Available", "Be right back", "Appearing Away")){
"[$date] user status set to $($status.availability), light should be off"
meetingStop
$LastState = $status.Availability
}
else{
"[$date] user status set to $($status.availability), light should be on"
meetingStart
$LastState = $status.Availability
}
start-sleep -Seconds $sleepInterval
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment