Return value from PowerShell function -


i writing function determine our reboot cycle. works, can't return value (should 1 or 2). idea might doing wrong?

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 } 

it's because neither of conditions returning true.

essentially you're running into..

if(10 >= 11 , 10 <= 17)... returns false

elseif( 10 >= 18 , 10 <= 24) returns false

else break hitting here , breaking


Comments