PowerShell: Trigger IFTTT Maker Channel using PowerShell v2


I’m in an environment where only PowerShell version 2 is available, which limits functionality and forces me into workarounds. I’ve been interested in using the Maker Channel on IFTTT in PowerShell for some time, but everybody seems to be using Invoke-RestMethod, which is unavailable in PowerShell v2. The following function uses the .NET object System.Net.WebClient to accomplish the trigger in the older version.

You have to create your trigger first on the IFTTT website (or mobile app) and include the three variables (or less, whatever), and link the associated action – I chose the “notification” option, which brings the trigger to my attention on my phone. This, of course, is incredibly versatile – you could set it up to notify somebody else, via text message, phone call, email, or whatever. IFTTT has an awesome collection of ways to act on the trigger. Check it out.

Note: There seems to be a problem with including spaces in the values sent. I’m just not including them, working fine now.

#EXAMPLE USAGE: iftttnotify "work_info" "reports" "accounting" "completed"
function iftttnotify ([string]$triggername,[string]$value1, [string]$value2, [string]$value3)    
    $privatekey ="YOUR_PRIVATE_KEY"
    $NVC = New-Object System.Collections.Specialized.NameValueCollection
    $WC = New-Object System.Net.WebClient
    $WC.UseDefaultCredentials = $true
    $Result = $WC.UploadValues($URL,"POST", $NVC);

Leave a Reply

Your email address will not be published. Required fields are marked *