IFTTT_Maker_PowerShell.psm1

<#
    .SYNOPSIS
        Triggers an event on the IFTTT Maker Channel.
    .DESCRIPTION
        Send-Maker triggers an event on the IFTTT Maker Channel.
        The event can have up to 3 values that can be passed.
    .PARAMETER EventName
        The name of the event to trigger on the IFTTT Maker Channel.
    .PARAMETER Key
        The secret key you got from IFTTT for triggering events on the Maker Channel.
    .PARAMETER Value1
        First value passed to the event (ingredient Value1).
    .PARAMETER Value2
        Second value passed to the event (ingredient Value2).
    .PARAMETER Value3
        Third value passed to the event (ingredient Value3).
#>

function Send-IFTTMaker
{
    [CmdletBinding()]
    param
    (
        [Parameter(HelpMessage="The secret key you got from IFTTT for triggering events on the Maker Channel.")]
        [string] $Key,
        
        [Parameter(HelpMessage="The name of the event to trigger on the IFTTT Maker Channel")]
        [string] $EventName,
        
        [Parameter(HelpMessage="First value passed to the event (ingredient Value1).")]
        [string] $Value1,
        
        [Parameter(HelpMessage="Second value passed to the event (ingredient Value2).")]
        [string] $Value2,
        
        [Parameter(HelpMessage="Third value passed to the event (ingredient Value3).")]
        [string] $Value3
    )

    $Site="https://maker.ifttt.com/trigger/"
    if(-not($Key)) { Throw �You must supply a value for -Key� }
    if(-not($EventName)) { Throw �You must supply a value for -EventName� }
    if(-not($Site)) { Throw �You must supply a value for -Site� }

    [uri]$MyURL = "$Site$EventName/with/key/$Key"
    $BodyDic= @{}

    if($Value1)
    {   $BodyDic.value1=$Value1
        if($Value2)
        {   $BodyDic.value2=$Value2
            if($Value3)
            {    $BodyDic.value3=$Value3}}}
    
        $BodyJson = ConvertTo-Json $BodyDic

    Invoke-WebRequest -Uri $MyURL -Method Post -ContentType "application/json" -Body $BodyJson
}