none
Script execution based on time RRS feed

  • Question

  • hi

     how can i execute a part of script based on current time

    $timenow = get-date | select hour,minute
    $sce= $timenow.Hour -eq '08' -and $time.minute -le '30'
    if ($sce-eq "true"){execute}

    if ($sce-eq "false"){execute}

    this script will execute true things when the time is less than 8 30 i.e between 8 and 8 30 and execute false things during the other time, is it right approach?

    Monday, August 3, 2015 8:46 AM

Answers

  • This may work better - 

    $timenow = get-date | select hour,minute
    $sce = $timenow.Hour -eq '8' -and $timenow.minute -le '30'
    if ($sce){"True"}
    else{"False"}

    Monday, August 3, 2015 9:12 AM