# multi-file.ps1 — report freshness of several files + drive free pct. $Url = "YOUR_URL/multi-file" $Files = @{ report = "C:\Reports\daily.csv" backup = "C:\Backups\latest.bak" log = "C:\Logs\app.log" } $Stats = @{} foreach ($name in $Files.Keys) { $path = $Files[$name] if (Test-Path -LiteralPath $path) { $age = [int]([DateTime]::UtcNow - (Get-Item -LiteralPath $path).LastWriteTimeUtc).TotalSeconds $Stats[$name] = @{ exists = $true; age_seconds = $age } } else { $Stats[$name] = @{ exists = $false; age_seconds = -1 } } } # Drive free % $Drive = Get-PSDrive -Name C $FreePct = if ($Drive.Used + $Drive.Free -gt 0) { [math]::Round(($Drive.Free / ($Drive.Used + $Drive.Free)) * 100, 1) } else { 0 } $Body = (@{ hostname = $env:COMPUTERNAME files = $Stats drive_c = @{ free_pct = $FreePct; free_gb = [math]::Round($Drive.Free / 1GB, 2) } }) | ConvertTo-Json -Compress -Depth 6 Invoke-RestMethod -Uri $Url -Method Post -Body $Body ` -ContentType "application/json" -TimeoutSec 15 | Out-Null