Skip to content

Instantly share code, notes, and snippets.

@darrenjrobinson
Last active September 6, 2016 22:42
Show Gist options
  • Save darrenjrobinson/ec51b0545b618181adbbf24deb789c4a to your computer and use it in GitHub Desktop.
Save darrenjrobinson/ec51b0545b618181adbbf24deb789c4a to your computer and use it in GitHub Desktop.
# Make my status Away
$postParams = @{availability="Away"} | convertto-json
$response = Invoke-WebRequest -Uri ($baseurl+$meurl.self.href+"/presence") -Method POST -Headers @{"Authorization"="Bearer $authcwt"} -Body $postParams -ContentType "application/json" -UseBasicParsing
# Make my status Busy
$postParams = @{availability="Busy"} | convertto-json
$response = Invoke-WebRequest -Uri ($baseurl+$meurl.self.href+"/presence") -Method POST -Headers @{"Authorization"="Bearer $authcwt"} -Body $postParams -ContentType "application/json" -UseBasicParsing
# Make my status Online
$postParams = @{availability="Online"} | convertto-json
$response = Invoke-WebRequest -Uri ($baseurl+$meurl.self.href+"/presence") -Method POST -Headers @{"Authorization"="Bearer $authcwt"} -Body $postParams -ContentType "application/json" -UseBasicParsing
# Make my status Do not disturb
$postParams = @{availability="Donotdisturb"} | convertto-json
$response = Invoke-WebRequest -Uri ($baseurl+$meurl.self.href+"/presence") -Method POST -Headers @{"Authorization"="Bearer $authcwt"} -Body $postParams -ContentType "application/json" -UseBasicParsing
# Get my Contacts
$response = Invoke-WebRequest -Uri ($baseurl+$peopleurl.myContacts.href) -Method Get -Headers @{"Authorization"="Bearer $authcwt"} -ContentType "application/json" -UseBasicParsing
$myContacts = $response.Content | ConvertFrom-Json
$myContacts._embedded.contact | Out-GridView
# Get the presense status of my contacts
$myContactsLinks = $(($response.content | ConvertFrom-JSON)._embedded.contact._links)
foreach ($contact in $myContactsLinks.contactPresence.href){
$presense = Invoke-WebRequest -Uri $($baseurl+ $Contact) -method GET -Headers @{"Authorization"="Bearer $authcwt"} -ContentType "application/json" -UseBasicParsing #| ConvertFrom-JSON | Select -ExpandProperty availability
$contactPresense = $presense.Content | ConvertFrom-Json
write-host $Contact.split("/")[7..7] "is on a" $contactPresense.deviceType "and is" $contactPresense.availability
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment