Last active
August 16, 2018 00:39
-
-
Save yumura/428570d4b02a82b511fd5a194d6e68dc to your computer and use it in GitHub Desktop.
PowerShell から IFTTT 経由で LINE Notify
This file contains 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
[CmdletBinding()] | |
Param | |
( | |
[ValidateNotNullOrEmpty()] | |
[string] $Title = "", | |
[parameter(ValueFromPipeline=$true)] | |
$Value, | |
[string] $PhotoURL, | |
[string] $Delimiter, | |
[switch] $PassThru | |
) | |
Begin | |
{ | |
$event = "Write-LINE" | |
$key = throw "Your key" | |
$BoundParameter = @{ | |
Method = "Post" | |
URI = "https://maker.ifttt.com/trigger/${event}/with/key/${key}" | |
Body = @{ | |
value1 = "" | |
value2 = $PhotoURL | |
} | |
} | |
$list = New-Object System.Collections.ArrayList | |
if (-not [string]::IsNullOrEmpty($Title)) {[void]$list.Add($Title)} | |
} | |
Process | |
{ | |
if ($PassThru) {$Value} | |
[void]$list.Add($Value) | |
} | |
End | |
{ | |
$BoundParameter.Body.value1 = | |
if ([string]::IsNullOrEmpty($Delimiter)) {Out-String -InputObject $list} | |
else {$list -join $Delimiter} | |
Invoke-RestMethod @BoundParameter | Write-Verbose | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment