So my script looks like this
1$UserIopsIntervalInput = Read-Host "(IOPS - sample interval), How often do you want a sample taken (in seconds, default is 1)"
2$UserIopsPeriodInput = Read-Host "(IOPS - time to run), How long do you want to run your samples for (in seconds, default is 7200)"
3$IOPsJobsInput = Read-Host "(IOPS - Job amount), How many times would you like to execute (IOPS - time to run)"
4
5$RunNow = Read-Host "Would you like to run this script now (y/n)"
6
7IF ($RunNow -eq "n")
8
9{
10$RunWhen = Read-Host "When would you like to run the script (In Seconds)"
11Start-Sleep $RunWhen
12}
13
14$workingdir = "$installpath\tmp\"
15$scriptpath = "C:\Program Files\BSTATS\bid-perfget.ps1"
16
17
18"BSTATS running...."
19
20foreach($i in (1..$UserIopsPeriodInput)) {
21 $percentage = $i / $UserIopsPeriodInput
22 $remaining = New-TimeSpan -Seconds ($UserIopsPeriodInput - $i)
23 $message = "{0:p0} complete, remaining time {1}" -f $percentage, $remaining
24 Write-Progress -Activity $message -PercentComplete ($percentage * 100) -Status "Working, Please Wait ..."
25 Start-Sleep 1
26}
27
28for ($i=0; $i -lt $IOPsJobsInput; $i++) {
29$currentdatetime = Get-Date -format M.d.yyyy.HHmmss
30
31$iopsargs = ($installpath, $customerident, $email, $emailserver, $computer, "IOPS", "IOPS-$customerident-$currentdatetime", 32
$UserIopsIntervalInput, $UserIopsPeriodInput, $workingdir)
33$iops = Start-Job -filepath $scriptpath -ArgumentList $iopsargs
34
35Wait-Job $iops
36
37Remove-Job $iops
38
39}
It all works great except what I would like to know is how I can have it so if they just hit [ENTER] then it will use the default value. for example.
in line 1:
$UserIopsIntervalInput = Read-Host "(IOPS - sample interval), How often do you want a sample taken (in seconds, default is 1)"
If the user just hits [ENTER], I would like it to use the default value of "1"
I'm not sure how I can do that.