I need a Powershell script which will open 3 URLs at a random time. The time between 10 to 15 mins and will run continuously Until killing the task Steps are:
powershell.exe -noprofile -command "Invoke-WebRequest -Uri http://your_url"
Assuming you just need to fire the request and don't care about the response, you can use Get-Random
and Start-Sleep
to sleep for a random interval between 10 and 15 minutes:
$URLs = @(
'http://site.tld/url1'
'http://site.tld/url2'
'http://site.tld/url3'
)
$minSeconds = 10 * 60
$maxSeconds = 15 * 60
# Loop forever
while($true){
# Send requests to all 3 urls
$URLs |ForEach-Object {
Invoke-WebRequest -Uri $_
}
# Sleep for a random duration between 10 and 15 minutes
Start-Sleep -Seconds (Get-Random -Min $minSeconds -Max $maxSeconds)
}