Last active
November 19, 2020 21:41
-
-
Save steviecoaster/5e6cb651a59810429f0c5c3224de1fd1 to your computer and use it in GitHub Desktop.
Mobile push notifications when installing Chocolatey packages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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