# file-modified.ps1 — post the age of a single file in seconds. $Url = "YOUR_URL/file-modified" $File = "C:\Path\To\Your\file.log" if (Test-Path -LiteralPath $File) { $Age = [int]([DateTime]::UtcNow - (Get-Item -LiteralPath $File).LastWriteTimeUtc).TotalSeconds $Exists = $true } else { $Age = -1 $Exists = $false } $Body = (@{ hostname = $env:COMPUTERNAME file = $File exists = $Exists age_seconds = $Age }) | ConvertTo-Json -Compress Invoke-RestMethod -Uri $Url -Method Post -Body $Body ` -ContentType "application/json" -TimeoutSec 15 | Out-Null