Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MattHodge/860eab6a4fce12eca251 to your computer and use it in GitHub Desktop.
Save MattHodge/860eab6a4fce12eca251 to your computer and use it in GitHub Desktop.
<#
.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 message when a Storage Spaces Pool, Virtual or Physical Disk is no longer of Health Status.
.DESCRIPTION
Windows 2012 R2 Storage Spaces provides CmdLets to monitor the status of Pool, Virtual or Physical Disk.
This script will send an alert if it notices anything is not Healthy, with the name of the server and the details.
Set this task up inside Task Scheduler
#>
$poUserID = "XXXXX"
$poToken = "XXXXX"
Import-Module PS-Pushover
# Check Storage Pools
$storagePoolStatus = Get-StoragePool | Where-Object {$_.HealthStatus -ne "Healthy"}
forEach ($storagePool in $storagePoolStatus)
{
$message = "($($env:COMPUTERNAME)) Storage Pool ""$($storagePool.FriendlyName)"" is $($storagePool.HealthStatus)."
Write-Output $message
Send-PushoverMessage -user $poUserID -message $message -token $poToken -priority 2
}
# Check Virtual Disks
$virtualDisks = Get-VirtualDisk | Where-Object {$_.HealthStatus -ne "Healthy"}
forEach ($vd in $virtualDisks)
{
$message = "($($env:COMPUTERNAME)) Virtual Disk ""$($vd.FriendlyName)"" is $($vd.HealthStatus). Operation Status is $($vd.OperationalStatus)."
Write-Output $message
Send-PushoverMessage -user $poUserID -message $message -token $poToken -priority 2
}
# Check Physical Disks
$physicalDisks = Get-PhysicalDisk | Where-Object {$_.HealthStatus -ne "Healthy"}
forEach ($pd in $physicalDisks)
{
$message = "($($env:COMPUTERNAME)) Physical Disk ""$($pd.FriendlyName)"" is $($pd.HealthStatus). Operation Status is $($pd.OperationalStatus)."
Write-Output $message
Send-PushoverMessage -user $poUserID -message $message -token $poToken -priority 2
}
<#
.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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment