Set Start and End date to the first and last day of the previous month
$StartDate = (Get-Date -Day 1 -Hour 0 -Minute 0 -Second 0).AddMonths(-1)
$EndDate = (Get-Date -Day 1 -Hour 0 -Minute 0 -Second 0).AddSeconds(-1)
Set Start and End date to the first and last day of the current month
$StartDate = (Get-Date -Day 1 -Hour 0 -Minute 0 -Second 0)
$EndDate = (Get-Date -Day 1 -Hour 0 -Minute 0 -Second 0).AddMonths(+1).AddSeconds(-1)
Set Start and End date to the first and last day of the previous week
$StartDate = (Get-Date (Get-Date).AddDays((Get-Date).DayOfWeek.value__*-1) -Hour 0 -Minute 0 -Second 0).AddDays(-7)
$EndDate = (Get-Date (Get-Date).AddDays((Get-Date).DayOfWeek.value__*-1) -Hour 0 -Minute 0 -Second 0).AddSeconds(-1)
Set Start and End date to the first and last day of the current week
$StartDate = Get-Date (Get-Date).AddDays((Get-Date).DayOfWeek.value__*-1) -Hour 0 -Minute 0 -Second 0
$EndDate = (Get-Date (Get-Date).AddDays((Get-Date).DayOfWeek.value__*-1) -Hour 0 -Minute 0 -Second 0).AddDays(7).AddSeconds(-1)
Comments
0 comments
Please sign in to leave a comment.