IFTTT_Maker_PowerShell.psm1
Set-StrictMode -Version Latest <# .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-Maker { [CmdletBinding()] param ( [string] $Key, [string] $EventName, [string] $Site="https://maker.ifttt.com/trigger/", [string] $Value1, [string] $Value2, [string] $Value3 ) 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� } $ValueString=""; [uri]$MyURL = "$Site$EventName/with/key/$Key" if($Value1 -ne "") { $ValueString =$ValueString+ '"value1" : "'+$Value1+'"' if($Value2 -ne "") { $ValueString =$ValueString+ ', "value2" : "'+$Value2+'"' if($Value3 -ne "") { $ValueString =$ValueString+ ', "value3" : "'+$Value3+'"' } } } if($ValueString -ne "") {$ValueString = "{"+$ValueString+"}"} $Result= Invoke-WebRequest -Uri $MyURL -Method Post -ContentType "application/json" -Body $ValueString return $Result.Content } |