Skip to content

Instantly share code, notes, and snippets.

@yumura
Last active August 16, 2018 00:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yumura/428570d4b02a82b511fd5a194d6e68dc to your computer and use it in GitHub Desktop.
Save yumura/428570d4b02a82b511fd5a194d6e68dc to your computer and use it in GitHub Desktop.
PowerShell から IFTTT 経由で LINE Notify
[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