@F4u5t, here's an example to watch a folder for new files, and call the IFTTT webhook.
$watcher = New-Object System.IO.FileSystemWatcher
$watcher.Path = 'D:\folder_to_watch'
$watcher.IncludeSubdirectories = $true
$watcher.EnableRaisingEvents = $true
$action =
{
$path = $event.SourceEventArgs.FullPath
$changetype = $event.SourceEventArgs.ChangeType
Write-Host "$path was $changetype at $(get-date)"
$postdata = @{
value1=$path
value2=$changetype
}
# To get your key, click the Documentation link at https://ifttt.com/maker_webhooks/
$key="your_ifttt_key"
$event="new_file"
$json = $postdata | ConvertTo-Json
$response = Invoke-RestMethod "https://maker.ifttt.com/trigger/$event/with/key/$key" -Method Post -Body $json -ContentType 'application/json'
write-host $response
}
Register-ObjectEvent $watcher 'Created' -Action $action
"Waiting for events. Press CTRL-C to quit."
while($true)
{
Start-Sleep .5
}