Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell做直到循环_Powershell - Fatal编程技术网

Powershell做直到循环

Powershell做直到循环,powershell,Powershell,第一个问题是,在语句$i=$startid+1之后,$i等于11,而不是2。 第二个问题是,即使until语句说它应该在$i-gt$stop时停止,循环仍然会永远继续 如何使$I增加1而不是10,以及如何在$I-gt$stop时停止循环。Read prompt每个默认值返回一个字符串这解释了不同的转换方式。您必须将字符串转换/强制转换为数值: $StartID = Read-Host -Prompt "StartID" $StopID = Read-Host -Prompt "StopID" $

第一个问题是,在语句$i=$startid+1之后,$i等于11,而不是2。 第二个问题是,即使until语句说它应该在$i-gt$stop时停止,循环仍然会永远继续

如何使$I增加1而不是10,以及如何在$I-gt$stop时停止循环。

Read prompt每个默认值返回一个字符串这解释了不同的转换方式。您必须将字符串转换/强制转换为数值:

$StartID = Read-Host -Prompt "StartID"
$StopID = Read-Host -Prompt "StopID"
$i = $StartID
do {
    Write-Host $startID
    Write-Host $StopID
    $i = ($StartId + 1)
} until ($i -gt $StopID)
希望对您有所帮助。

Read Prompt在默认情况下返回字符串这解释了不同的转换方式。您必须将字符串转换/强制转换为数值:

$StartID = Read-Host -Prompt "StartID"
$StopID = Read-Host -Prompt "StopID"
$i = $StartID
do {
    Write-Host $startID
    Write-Host $StopID
    $i = ($StartId + 1)
} until ($i -gt $StopID)
希望有帮助