Couple of ideas for finding the beginning and end of the week
Start of week
$s = get-date -hour 0 -minute 0 -second 0
End of week
$e = get-date -hour 23 -minute 59 -second 59
To find the start of the week – use get-date and set the time portion to zero i.e. midnight
Then use the AddDays() method to subtract the value of the current day of the week. Value__ is a property of a property – get-member to the rescue again!! This gives the start of the week.
End of the week is similar except set the time to 1 second to midnight and use AddDays() to add the number of days left in the week i.e. seven minus the value of the current day of the week.
|Share this post :|