Hi Everyone,

OK, so this is the first function I’ve uploaded in a while, I’ve been quite busy at work but I had to share this one as it’s very useful, and could be very useful to a lot of people. So here goes. :/

The function is fully commented and contains a comprehensive help section so you should be able to understand what it dose without reading this explanation.

This information can then be used in something like PowerBI to utilise it in a dashboard, i’m planning to make a guide so stay tuned!


So the basics is it’s a logging function that adds items to 2 SharePoint lists on the connected site.

One of them being an Overview of the process it’s logging the other having each event individually stated.

Detailed Overview

The function appends(or creates) 2 SharePoint lists, one is used as an Overview of the running processes (be it scripts or Workflow or anything running a series of commands) with information specified in the function parameters and the other a log of each action taken.

The “LogList” and “OverviewList” list are linked together by the Overview’s “ID” field generated when it’s created, passed by the -Passthru switch, this is then in turn referenced using the -ID parameter that’s populated in the “OverviewReferenceId” field, the function populates a new list item with the values of any specified parameters, most of which are optional.

These parameters are;

OverviewList“,”LogList“,”ProcessName“, “Step“, “CurrentStatus“, “Result“, “ProcessOwner“, “ProcessObjectCount“, “ProcessObjectCurrentItem“, “TargetObject“, “CommandRun“, “OverviewReferenceId“, “RunBy“, “HostSystem“, “ConnectedWithAccount“, “Errors“,”Notes“,”Passthru“,”SkipCheck“,”PreBuildLists“,”ID

So the first command in a process would look something like;

and each item in the process you’d like to log would look something like;


Notice that the first command stores the return value from using the -Passthru switch to a variable and then the following commands uses that variable in the -ID parameter, this essentially updates the OverviewList list item of that value with the values in the parameters stopping another OverviewList item.

There are a few Switch parameters;


This returns the OverviewList list ID number for use in subsequent uses of the function in the script.

This is useful to specify after the initial run on the function as it skips the checking portion of the function.

You can call this anywhere as it just builds the list in the connected site without adding any list items. (if you just want to see how the function creates the list or to pre-create them.

Default Parameters

SupportsShouldProcess is set to True and ConfirmImpact is set to High, this is why I use -Confirm:$false in the examples, this is is just a precaution as the function creates SharePoint lists in the connected site.

Required Paramters

OverviewList“,”LogList” are both required and reference the lists your logging will go in to.

Parameter Info

ProcessObjectCount“, “ProcessObjectCurrentItem” require an [System.Int32] (a number) and are optional.

Passthru“,”SkipCheck“,”PreBuildLists” are Switch Parameters and optional

The rest require [System.String] (Text) input and are optional


Default output of the command is [System.Void] or if -PassThru is specified [System.String]

Other Information

I use a function in the scrip called ConvertTo-CapitalSplit this is something i created just to Split By the Capital when converting the internal listed names to the displaynames.


This function uses and requires the module SharePointPnPPowerShellOnline

on systems running Powershell 4.0 and above can run the following commend to install it;

or instructions can be found at HERE

The function itself requires a minimum of PowerShell Version 3.0

You need to make sure that yo’ve handled the SharePoint connection yourself prior to calling the command.

Usually you’ll use something like;

$Creds being the created elsewhere in the script.

Function Functionality

So most of this is covered above but i’ll try and give you some example of how to utilise this function.

This is something i created to manage our O365 E5 licensing, as you can see the function is used in several steps and gives me details on whats happening in the script.

I’ve redacted all sensitive information so if you’d like to plagiarise the script (:p I don’t mind) you’d have to adjust it to your own needs.

The actual function

So here it is, I hope you find it useful, i’ll try and update as suggestion come in.


SharePoint related queries – James Beckenham – Senior SharePoint Specialist