Skip to content

Instantly share code, notes, and snippets.

@Kieranties
Last active April 12, 2018 23:53
Show Gist options
  • Save Kieranties/5564690 to your computer and use it in GitHub Desktop.
Save Kieranties/5564690 to your computer and use it in GitHub Desktop.
PS-Pushover Examples
<#
.SYNOPSIS
Calculate a high Fibonnachi number and send a Pushover message
#>
Import-Module PS-Pushover
Start-Job -ScriptBlock {
$current = $previous = 1;
while ($current -lt 1000000000) {
$current,$previous = ($current + $previous),$current
}
Send-PushoverMessage $current -title "Fibonnachi result" -user "user key" -token "user token"
}
<#
.SYNOPSIS
Send a high priority Pushover message when a new log file arrives
#>
Import-Module PS-Pushover
$watcher = New-Object System.IO.FileSystemWatcher -Property @{
Path = 'c:\logs'
Filter = '*.txt'
NotifyFilter = [System.IO.NotifyFilters]'FileName,LastWrite'
}
$action = {
$filename= $($event.sourceEventArgs.Name)
Send-PushoverMessage "$filename created" -title "New file" -user "user key" -token "api token" -priority 1
}
Register-ObjectEvent -InputObject $watcher -EventName Created -SourceIdentifier "New log file" -Action $action
<#
.SYNOPSIS
Send a message when a torrent has finished
.DESCRIPTION
uTorrent allows a script to be ran with various parameters when a torrent has finished downloading
or its state has changed.
Settings can be found at Options -> Preferences -> Advanced -> Run Program
Set the option Run this program when a torrent finishes" to the following
powershell.exe -ExecutionPolicy Unrestricted -File C:\Pushover-uTorrentNotify.ps1 %N
#>
Import-Module PS-Pushover
Send-PushoverMessage -title "Download Finished" -message $args[0] -sound "cashregister" `
-user "user key" -token "api token"
@MattHodge
Copy link

Hey there. Thanks for the nice module and examples. I have added another example if you would like to add it your list: https://gist.github.com/MattHodge/860eab6a4fce12eca251#file-pushover-monitorstoragespaces-ps1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment