我正在编写一个函数来确定我们的重启周期。它有效,但我不能让它返回一个值(应该是1或2)。知道我可能做错了吗?
function Get-BootCycle {
$devEarliest = 8
$devLatest = 14
$prodEarliest = 15
$prodLatest = 21
$today = Get-Date
switch ($today.DayOfWeek) {
Wednesday {$val = 1}
Thursday {$val = 2}
Friday {$val = 3}
Saturday {$val = 4}
Sunday {$val = 5}
Monday {$val = 6}
Tuesday {$val = 7}
}
$dateVal = "'" + [string]$val + "." + ([string]$today.Hour) + "." + $today.AddMinutes(-($today.Minute % 30)).Minute + "'"
if ($today.Day -ge ($devEarliest + $val) -and $today.Day -le ($devLatest + $val)) {
$bootCycle = "Development"
$bootCycleVal = 0
}
elseif ($today.Day -ge ($prodEarliest + $val) -and $today.Day -le ($prodLatest + $val)) {
$bootCycle = "Production"
$bootCycleVal = 1
}
else {
Break
}
return $bootCycleVal
}
答案 0 :(得分:3)
这是因为你的条件都没有恢复。
基本上你正在进入..
if(10> = 11 AND 10< = 17)... 返回false
elseif(10> = 18 AND 10< = 24)返回false
其他打破点击此处并打破