So i am scheduling a job to run every 30 minutes. Sometimes, the job runs at 4:31, sometimes at 4:34. I need it to process everything in a CSV if the time in the csv is 4:30, 5:30, 6:00 etc.
I’m sorry if that’s confusing, maybe this csv will help:
name,date,time Jorge,06/29/2016,4:30 PM
So my script looks like this:
$Users = import-csv C:users.csv $TimeNow = Get-Date -f t $Date = Get-Date -f MM-dd-yyyy foreach ($User in $Users) { if ($User.TIME -eq $TimeNow -and $User.Date -eq $Date) { write-host "Do this" } }
The problem is, if the script is ran at 4:31, it obviously doesn’t process the users in the CSV where the time is 4:30. How can i make it so it processes the users if the time is greater than or equal to 4:30, but less than 4:59? I don’t know how i can gather the time if the script is run at 4:31 and make it round off so i processes users that’s time in the CSV is 4:30
submitted by /u/MoneyMiddleton
[link] [comments]
The post Help with time-based script? appeared first on How to Code .NET.