Thursday, March 28, 2013

Find your phone with Tasker and Pushover

Tasker is a tool to automate almost anything on Android. I use it to adjust volumes on a schedule, turn off pattern lock screen at home, etc. I will write more posts about Tasker, but if you want to try it out there's a 7-day trial version on the Tasker site, and a full, paid version on Play Store. I can recommend the Pocketables Beginner's Guide to Tasker series, the Userguide on Taskers web site and this Tasker Wiki

I already mentioned Pushover in a previous post, but essentially it's a tool to send notification to mobile devices (Android and iOS).

I wanted a way to locate my mobile phone in case it's lost. There are many apps that can do this already, but with Tasker you can do it yourself. I didn't even have to figure out how to do it myself, as a good recipe  is already available on a Tasker Wiki. There are some variants on that site and I ended up with the tasker code below.
To find your phone, send a text message to your lost from from any other mobile phone with <your keyword> in the message. Tasker will trigger, get the phone location using any of the methods available (GPS or WiFi positioning) and send back a text message with a Google Maps URL with your lost phones position mapped out.

Tasker Profile
Profile: LocateSMS (2)
Event: Received Text [ Type:Any Sender:* Content:<your keyword> ]
Enter: LocationPushover (3)

Tasker Task
LocationPushover (3)
A1: Get Location [ Source:Any Timeout (Seconds):120 Continue Task Immediately:Off Keep Tracking:Off ]
A2: Variable Set [ Name:%LOCATION To:%LOCN Do Maths:Off Append:Off ] If [ %LOC ! Set ]
A3: Variable Set [ Name:%LOCATION To:%LOC Do Maths:Off Append:Off ] If [ %LOC Is Set ]
A4: Send SMS [ Number:%SMSRF Message: Store In Messaging App:Off ]
A5: Variable Clear [ Name:%LOCATION Pattern Matching:Off ]

This is nice, but since I've started to use Pushover for notifications I wanted to try that out as well. Reading up on the Pushover API I figured the easiest way is to do a HTTP Post from Tasker with a properly formatted Path. Since I want to send a URL in the notification message I need to URL encode it, otherwise Pushover API would try to interpret the /, ? and & as part of the API URI. I URL encoded the Google Maps 

URL part and ended up with a new step four in the Tasker Task.

A4: HTTP Post [ Server:Port: Path:/1/messages.json?user=<user token>&token=<app token>&title=Phone+location& Data / File: Cookies: Timeout:10 Content Type:application/x-www-form-urlencoded Output File: ]
URL Encoding is easy. A good guide is available at the website. This URL:
is turned into this:

In addition to the Tasker script, I created a new Pushover application, added a Google Maps icon and that was it. When I send a text with my keyword I get the following Pushover notification on all my devices.

If you want to use the code above, you just need to change <your keyword> to a keyword of your choice. This is the word you need to text to your lost phone to trigger the Tasker Profile and Task. In the code you also need to replace <user token> and <app token> if you want to use Pushover.

Wednesday, March 27, 2013

Get notified when your computer reboots using Pushover

Pushover is a platform for sending and receiving push notifications to mobile devices (Android and iOS). Pushover is free, but requires the installation of a paid app on your Android or iOS device. After you set up your account on Pushover you get a user token that is used to identify you as the sender of a notification.
To send notifications, create a new application on the Pushover site. Give it a name, select type and upload an icon. After the application is registered you get an application token that identifies your application.

OK, so I wanted a notification sent to my phone whenever my computer restarted. Since it's a Windows 8 computer I decided to go for PowerShell 3.0 and created the following script:
$uri = ""
$parameters = @{
  token = "<app token>"
  user = "<user token>"
  title = "Reboot"
  message = "Your computer just rebooted"
$parameters | Invoke-RestMethod -Uri $uri -Method Post
Nothing special about the script, basically it's a slight modification of an example script found on the Pushover FAQ. Just replace <app token> and <user token> with your own tokens.

Next, I need to have the script run when the computer starts, and run before anyone logs on. That's the point, right, if I'm at the computer I don't need a notification telling me the computer restarted.
Run the Local Group Policy Editor (gpedit.msc) tool as administrator and drill down to Local Computer Policy -> Computer Configuration -> Windows Settings -> Scripts and open Startup.

Go to the PowerShell Scripts tab and click Add. Click Browse next to Script Name and locate your script. Click OK, OK and then close the policy editor.

All done!

Monday, March 25, 2013

PowerShell Books

Just found ( that lists a number of PowerShell books, and also provides three books for free download in PDF format.

Thursday, March 14, 2013

Free Microsoft ePub and PDF Books

When setting up a Lync 2013 server I came across "Microsoft Lync Server 2013 Step by Step for Anyone" eBook by Matt Landis available for free on the Microsft TechNet site.

Microsoft Lync Server 2013 Step By Step for Anyone eBook cover

Turns out, there are a lot of books available for free in various formats from the TechNet eBook Gallery (scroll down) and from Microsoft Press Blog. I haven't yet found a complete listing, and maybe one doesn't exist.