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 = "https://api.pushover.net/1/messages.json"
$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!

6 comments:

  1. This is exactly what I'm seeking. BUT I cannot get it to Run in PowerShell 2.0 (Win764Bit PC.)
    Error below: The term 'Invoke-RestMethod' is not recognized as the na
    ck the spelling of the name, or if a path was included,
    At C:\Users\GServer\Documents\Scripts\PushReboot.ps1:8 c
    + $parameters | Invoke-RestMethod <<<< -uri $uri -Metho
    + CategoryInfo : ObjectNotFound: (Invoke-Re
    + FullyQualifiedErrorId : CommandNotFoundException

    Can anyone please help to get this working in Powershell 2 - I've even tried upgrading to Powershell 3, but that just hangs at Initialising Install.

    ReplyDelete
  2. The market for Apple computers is tightly controlled. This means that Apple computers work very well with few problems. They are seldom attacked by malicious software. Click here

    ReplyDelete
  3. Some can be downloaded, like iTunes or Adobe Acrobat Reader. Any that you paid for, such as Microsoft Office, however, will likely be on CD/DVD. reset windows 10 password

    ReplyDelete
  4. Renting a computer instead of buying means you don't have to spend money on upkeep. Buzzbeasts's all in one pc

    ReplyDelete
  5. For this, you need to comprehend your necessities and spending first. A lot of great speakers can interfere with you by over $200, while you can get an 'enough' useful speaker framework for under $50. read review

    ReplyDelete
  6. Certsout.com provides authentic IT Certification exams preparation material guaranteed to make you pass in the first attempt. Download instant free demo & begin preparation. Community-Cloud-Consultant exam questions answers

    ReplyDelete