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

Occasional Visitor

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 :

$file="C:\Users\sapantha\Downloads\Adtalem_collection.csv"
$data=import-csv $file
$results= $data | WHERE {$_.Collection_Name -eq "NoReboot"}
$results
$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){
$item

 

Write-Host "will start reboot"

 

}else{
Write-Host "waiting till time zone falls under maintenance "
}

 


}

---------------------------------

 I have attached the reference picture 

0 Replies