Play with PowerShell DateTime – Orchestrator Conditional Wait!

A colleague asked me a script to trigger an event on 5th business day from the date of submission.

Changing the script condition for management is hell! We need reminder in one business day, no well make it two! Hang on, keep it for 5 business day!

Here is the requirement! When user submit a request form it sends form details to third party orchestrator where the logical flow is built and codes are injected in palette for enacting the request. In a given requirement team should fire a reminder email on 5th business day! For example, today is 3/8/2018 adding 5 days to it give 3/13/2018 and excluding weekends i.e Saturday and Sunday it’s 3/15/2018 which is the 5th business day!

There are plenty of articles over internet which demonstrates the DateTime class in PowerShell. So, nothing new I can share expect this extension 🙂

Find next business for given day

In our case we need to find 5th business day but it’s business process right it may change often! Here is the sample code!

returns Wednesday, February 28, 2018 11:46:10 AM 

Parameterization – Just change as required!

Wednesday, February 28, 2018 11:54:33 AM

Published by

Chen V

I am a SharePoint 2010 IT Pro. My area of interests are Workflows, Automation, Office 365 , Identity and Access Management, PowerShell and Windows Servers.

Leave a Reply

Your email address will not be published. Required fields are marked *