Random timeout / pause in Windows scripting via PowerShell
Using PowerShell to do a random timeout to space out events & timing.
If you’re running a Batch file, or PowerShell script; and you need the computer to stop for a bit so you can have it catch up on some background task / not overload a file server / not DDoS some external website… PowerShell seems to make it decently easy to put a random timer in to stagger your jobs with. Name this file randpause.ps1
echo "Pausing script for 1-5 minutes to avoid overloading / rate-limiting / false DDoS"
$seconds = Get-Random -Minimum 60 -Maximum 300
Start-Sleep -Seconds $seconds
If you’re using a Batch (BAT) file, you’ll need to invoke PowerShell to run the script.
PowerShell.exe -ExecutionPolicy Unrestricted -command "randpause.ps1"
References#
Read other posts