I am writing a function to determine our reboot cycle. It works, but I can't get it to return a value (should be a 1 or a 2). What might I be 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
}
[int]($today.DayOfWeek)instead of using the swtich([int](Get-Date).DayOFWeek + 5) % 7