我需要一个Powershell脚本,该脚本会随机打开3个URL。 10到15分钟之间的时间,将持续运行直到终止任务步骤是:
powershell.exe -noprofile -command "Invoke-WebRequest -Uri http://your_url"
假设您只需要触发请求而不关心响应,则可以使用Get-Random
和Start-Sleep
睡眠10至15分钟的随机间隔:
$URLs = @(
'http://site.tld/url1'
'http://site.tld/url2'
'http://site.tld/url3'
)
$minSeconds = 10 * 60
$maxSeconds = 15 * 600
# 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)
}