# folder-monitor.ps1 — file count + total size in a folder. $Url = "YOUR_URL/folder" $Folder = "C:\Backups" if (-not (Test-Path -LiteralPath $Folder)) { $Body = (@{ hostname = $env:COMPUTERNAME; folder = $Folder; exists = $false }) | ConvertTo-Json -Compress } else { $Items = Get-ChildItem -LiteralPath $Folder -Recurse -File -ErrorAction SilentlyContinue $Total = ($Items | Measure-Object Length -Sum).Sum $Largest = ($Items | Measure-Object Length -Maximum).Maximum $Body = (@{ hostname = $env:COMPUTERNAME folder = $Folder exists = $true file_count = $Items.Count total_size_gb = [math]::Round(($Total / 1GB), 3) largest_file_gb = [math]::Round(($Largest / 1GB), 3) }) | ConvertTo-Json -Compress } Invoke-RestMethod -Uri $Url -Method Post -Body $Body ` -ContentType "application/json" -TimeoutSec 15 | Out-Null