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

Microsoft Word VSTO ADDIN – Retrieve SharePoint Site List Information Using CSOM

A friend of mineΒ Erdem Avni Avni SELΓ‡UKΒ from Turkey showed a video sample which retrieves SharePoint Online list column information in Excel! Truly amazing stuff for SharePoint IT Professionals Β at least for me. So, thought of Sharing my demo code which simply lists all SharePoint list title and includes a header text and footer with image in word document. This is very ugly code but may give some dice for IT Pro’s for customizing and building the solution as desired for content managers.

This is our output – Modified the image so header and footer will be visible



Step 1: Create a a Office VSTO office 2013 / 2016 addin solution using Visual Studio – Start From here

Step 2: Add a new item to the solution and choose Ribbon – it’s an xml file! – Start From here

Step 3: Install CSOM SDK assemblies πŸ™‚ πŸ™‚ πŸ™‚ – Below is the sample code

Continue reading Microsoft Word VSTO ADDIN – Retrieve SharePoint Site List Information Using CSOM

Part 3 – Getting Started With CSOM | SharePoint Online | PowerShell


In our last blog series we have seen few concepts of PowerShell CSOM like creating functions and including comments based help for our PowerShell functions in the module. Reference Links is below

In this article we will demo about adding format files to get desired output.

What is Format File?

Why we need to add format file? The very simple reason is to define display the object in command line. For example check the output of Get-Service cmdlet. By default it shows the properties like Status, Name and DisplayName which is defined in the file DotNetTypes.Format.ps1xml. Please use this for reference and do not modify it to avoid tampering of your existing view in PowerShell. So, when we run Get-Service we get three properties in output by default and to see more we either do one of the below as required
111. Okay, with this reference we will create our own Format File and name it as SPOnlineModule.Format.PS1XML and the location is under our module folder. To make this article easy I am opting to make List View Basic

Get Started

Let’s make our job easy! I copied the code from the List View Basic and modified my PowerShell function to meet the requirement.

All we need to do is simple steps

  • Create a Format File and name it as SPOnlineModule.Format.ps1xml
  • Save the file inside your module directory
  • Include this file name in PSD1 file at FormatsToProcess = @(‘SPOnlineModule.Format.ps1xml’)
  • Import the Module
  • Connect to SharePoint Online and execute Get-xSPOList cmdlet which yields only two properties Title and ItemCount.

Just as an example I am selecting first 5 list and the output is illustrated below
Note: We haven’t fixed the Connect-xSPOTenant cmdlet yet! We need to add Conditional Scope to make it more friendly.

In our Get-xSPOList cmdlet I included the below code which appends the view name to the PSCustomObject


SharePoint Content Management using PowerShell | Dude! it’s a Due Diligence – Part 1

October-26-2015: Due to SharePoint tasks I missed MVP Summit 2015; Energy drained out due to disappointment!. So, I engaged 16 hours of my time with SharePoint team to perform a due diligence. Traveled in and around Netherlands for consultations with clients, developers and IT Professionals.

Introduction: Though we know each other we gathered at a party lounge for a friendly handshake and a BIER πŸ™‚ and that’s Hertog Jan a typical Dutch Bier!



Not huge if we are four in numbers to share! – Cheers!!!

Challenge 1: Our security team will not allow us to install any third party components and products not guaranteed by Microsoft. So, we need to code to inventory of SharePoint farm(s). Includes MOSS 2007 & WSS 3.0,Β  SharePoint 2007 and SharePoint 2013.

Challenge 2: Developer team is busy in SharePoint Online training, we can engage them only twice a week.

Challenge 3: We need to plot a blue print of SharePoint farm without third party tools. The same needs to be shared with IT Managers before we design a plan for deployment or migrations or transformations.

πŸ™‚ πŸ™‚ πŸ™‚ Let’s keep the challenges apart. We may come across many while working on the Test and Production environment. So, we decided to get back to work on October-27-2015 with fresh mind! Yeah! we concluded not to work at home or not even to bing for solutions a day prior to work. A fresh mind is most important to work independently!

Requirement 1: Get all the items from Large List – We can see 30,000 + items we need a report in Excel.

I quickly showed the option in ribbon “Export to Excel” πŸ™‚ “Assuming things will not help at work place!” Clients need Large List items reports to be shared in email and uploaded SharePoint portal. If it’s in portal why in email? To gain customer satisfaction we stopped asking questions, we gathered our tasks and grabbed a cup of coffee to our desk.


oops! That’s not a large list, it’s a Document Library enabled with Document Set! The complete web is built and deployed using custom code. Exploring is not a challenge but need to be handled it with care. Many columns are Interconnected or mapped with multiple lists in the same web.

CAML Query is SharePoint IT Professionals best friend, Just three things we need to do Query, Select Fields, and set Attributes to do this we need a tool; Indeed that will be PowerShell. The mission begins now!


Dude, that’s SharePoint 2010 hosted on Windows 2008 R2 Standard. PowerShell Version 2.0 πŸ™‚ πŸ™‚ πŸ™‚ – Developers Team looked at me and laughed – Do you remember this version? Can we raise a request to upgrade the version of PowerShell? (Nope! PowerShell 4.0 stable version requires some workaround in SharePoint box and PS 5.0 Product Preview is not stable version) shall we do a timer job? (No! No! No! – Folks, don;t forget MOSS 2007 we did many without Shell Mangement – Now, we have a tool to manage!. Go and Check your Visual Studio version and updates – I assume you may need one more Bier!)

Dusted up my old SharePoint script file and modified it as required

Step 1: Export – Items to CSV

Step 2: Send in email as attachment and close the requirement!

Requirement 2: We have removed the existing Approval Workflow and lost the track of Content Approved Items – We can get that in search result.

Yes, this time no SharePoint Shell Management, kicked on Windows PowerShell 5.0 Product Preview from my local machine and got the report. Lucky me! the SharePoint document library will not allow duplicate items πŸ™‚ so, search results returns one URL (customized search page!) and team didn’t reset the Search Index πŸ™‚ “25% of the tasks completed – Yes, users can search and read contents from the application

The items found in search results URL will be re-processed : Set Content Approval to $true πŸ™‚

Requirement 3: Approve all documents – No need to think about the tasks which are already fired. So, concluded to change moderation status information to approved for the items found in search result.

Content mangers did a sanity checks and confirmed all set to good! So, it’s time for us to deploy new (or) upgraded solution. Moved to look at developer team. Oops! really pity – a laptop with 4 GB RAM running Visual Studio 2010 in SharePoint Development environment.


It’s lunch time πŸ™‚ πŸ™‚ πŸ™‚ we have few more fun to flow in! Gained energy with BitterBal


Continued discussion with development at lunch and assessed the challenges – We discussed about buying some more time πŸ™ “My Mind voice: I could have been to MVP Summit 2015!”. That was just a discussion not a conclusion; Post lunch we were back at desk to continue content management automation.

I requested developer to ignore all exiting πŸ™‚ DOC LIB items and automation tasks. So, they can develop ASP.NET form to map with DOC LIB columns – Yayyyyyy! Now we have Metadata Columns in the library! – Need a coffee! πŸ™‚

Requirement 4: Deploy the new solutions – Yep deploying new WSP! One liner using PowerShell – Deployment went fine and development team signed off (Will be back into production support as required), But Application didn’t turned up well!

It’s time for us to show the Power of Shell πŸ™‚ πŸ™‚ πŸ™‚

I expected the below shiny error πŸ™‚ But I should explain this to IT Managers like “sorry, we are encountering an unexpected error


πŸ™‚ Woot! Go ! Open up SharePoint Management Shell and execute the below piece of code with start and end time parameters – Pipe and fetch the correlation ID. It’s that simple!

Start Time : Grab it from the error screen shot

End Time : Just increase by 1 minute or 2 (Assumption!)

“Missing LCID for <Column>” πŸ™‚ he he he. Missing English and French!

New solution includes new fields which is set to be mandatory; managed term store now need two more language English and French – Dutch is by default!

Okay, I had the service packs binaries so installed English and French Language Packs to confirm the fix- Voila! we were back on track – 45% of the tasks accomplished! Note: If you are in RTM – Download the latest service pack – Extract and Delete any entries in Update folder which is in the year 2013. So, you can install the SharePoint 2010 Service Packs as RTM and upgrade to the current farm build version id required.

We have done only the initial phase of the work. Few more SharePoint 2010 IT Professional tasks are shared below

  1. Update all missing fields.
    • How to find the missing fields? We may have newly added columns πŸ™‚
  2. Read other list and update the DOC LIB.
    • Dude! it’s Note Field so we have HTML tags Export and Import in PowerShell or editing in DOC LIB using data sheet looks ugly πŸ™
  3. Approve all the approved items in the DOC LIB.
    • After manipulating the items – Approve the items if it was approved and pending should remain as pending. πŸ™‚ We haven’t touched workflow
  4. Most of the information are rendering in SharePoint portal by reading Active Directory.
    • Few users left the organization – We need to update author names with common ID (This is interesting πŸ™‚ )
  5. What happened to LYNC Presence in the SharePoint portal? LYNC Client is upgraded to Skype for Business. Need to investigate further more! May be browser add in!
    • Not my cup of tea though still I will figure out the reason!
  6. Who created the item? Who Modified the same?
    • We sorted this – But will discuss this again!
  7. Read the department of author and update it in the DOC LIB field (This is very interesting task because we need to explore User Profile Service Application)
  8. Complete the content automation – After all set to good we will start the due diligence for migrate the farm to SharePoint 2013. Or, will think about a POC using SharePoint 2016 Technical Preview!
    • I am waiting ! Not, that easy but possible!
  9. Mean while we need to upgrade the Operating System of MOSS 2007 – Since Windows 2003 server has no support we need to upgrade it to Windows 2008 R2 Standard and strictly needs to be in 32 bit.

More real time scripts, SharePoint Developer and IT Professional discussion about PowerShell will be continued in next blog πŸ™‚


Microsoft MVP Virtual Conference 2015


This is a great free event that Microsoft and the MVPs are putting on, May 14th & 15th. Join Microsoft MVPs from the Americas’ region as they share their knowledge and real-world expertise during a free event, the MVP Virtual Conference.

The MVP Virtual Conference will showcase 95 sessions of content for IT Pros, Developers and Consumer experts designed to help you navigate life in a mobile-first, cloud-first world. Microsoft’s Corporate Vice President of Developer Platform, Steve Guggenheimer, will be on hand to deliver the opening Key Note Address.

Why attend MVP V-Conf? The conference will have 5 tracks, IT Pro English, Dev English, Consumer English, Portuguese mixed sessions & Spanish mixed sessions, there is something for everyone!

Come learn from the best and brightest in the tech world today. All of the sessions will all be delivered by the Americas’ Region Microsoft MVPs. These MVPs are experts who present at premiere conferences, independent community events and local user groups all over the globe.

This is a technical conference focused on helping attendees to learn and develop skills for everything from everyday technical work to wackier weekend projects. Whether it is on the IT Pro, Dev or Consumer side of things, you can bet that the content of MVP V-Conf will be cutting edge, exciting and relevant.

Be sure to register quickly to hold your spot and tell your friends & colleagues.

The conference will be widely covered on social media, you can join the conversation by following @MVPAward and using the hashtag #MVPvConf.