Compare current time falls under given range of date-time,

Copper Contributor

my task is to

1.check for Collection_Name as NOReboot
2.identify the timezone
3.check if timefalls under maintenance window timings
4. if falls under maintenance timings , check for Name_of_the_service column
if service is abset , start reboot

if service is present , stop service --> reboot--> start service


My code :

$data=import-csv $file
$results= $data | WHERE {$_.Collection_Name -eq "NoReboot"}
$StartTime = $results.Maintenane_Window_start_time
$EndTime = $results.Maintenane_Window_end_time
$Current_time = Get-Date -Format "dd-MM-yyyy HH:mm:ss"

foreach($item in $results.Time_Zone,$StartTime ) {

if($Current_time -gt $StartTime -and $Current_time -lt $EndTime){


Write-Host "will start reboot"


Write-Host "waiting till time zone falls under maintenance "




 I have attached the reference picture 

0 Replies