Get-NextBusinessDay

I had a need to calculate the next business day in a script I was writing.

Pretty short and sweet.

 

Function Get-NextBusinesDay {
param($days)
$date = get-date
$newDate = $date.AddDays($days)
switch ($newDate.DayOfWeek)

    {
       "Saturday" {$newDate = $newDate.AddDays(2); $newDate}
       "Sunday"   {$newDate = $newDate.AddDays(1); $newDate}
       Default {$newDate}
    }
}

 

image

Comments are closed