Skip to content

Instantly share code, notes, and snippets.

@steviecoaster
Last active November 19, 2020 21:41
Show Gist options
  • Save steviecoaster/5e6cb651a59810429f0c5c3224de1fd1 to your computer and use it in GitHub Desktop.
Save steviecoaster/5e6cb651a59810429f0c5c3224de1fd1 to your computer and use it in GitHub Desktop.
Mobile push notifications when installing Chocolatey packages
Function Install-ChocolateyNotifyingPackage {
[cmdletBinding()]
param(
[parameter()]
[string]
$Package
)
process {
choco install $package -y -s https://chocolatey.org/api/v2
if($LASTEXITCODE -eq 0){
$title = "Choco Installed: $package"
$content = "The installation of $package on $($env:COMPUTERNAME) was successful"
}
else {
$title = "Choco installation FAILED"
$content = "The installation of $package on $($env:COMPUTERNAME) failed!!"
}
$body = @{
Title = $title
Content = $content
}
$params = @{
Uri = 'https://hook.notify17.net/api/raw/FooBarKey'
Method = 'POST'
ContentType = 'application/json'
Body = ($Body | ConvertTo-Json)
}
$null = Invoke-RestMethod @params
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment