Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.