Tool to run processes accros a SharePoint Online structure, from tenant to list items
After a few missions for customers, I had to do several scripts to audit SharePoint elements (structure of content) and did every time the same thing : a PowerShell which run accross the SHarePoint Object Model, site collection by site collection, sub-site by sub-site, list by list, etc, et finally export the informations to (mostly) a CSV file.
Because I don't like to do the same thing many times, I started a little projet for SharePoint Online, C# CSOM-based, to automatically run into SharePoint. It let me do only thing when a new mission / need comes : Get the informations for each element type (site, list, ...) or write the operation I need to do for each element type
The first step is to create a class which inherit from the Receiver class, from SharePointRunner.SDK.
This class can override these methods :
OnStart(): Executed at the very start of the process, can be used to setup a fileOnTenantRunningStart(Tenant tenant): Executed at the start of the process for the tenant and expose theTenantobjectOnTermStoreRunningStart(TermStore termStore): Executed at the start of the process for a term store and expose theTermStoreobjectOnTermGroupRunningStart(TermGroup termGroup): Executed at the start of the process for a term group and expose theTermGroupobjectOnTermSetRunningStart(TermSet termSet): Executed at the start of the process for a term set and expose theTermSetobjectOnTermRunningStart(Term term): Executed at the start of the process for a term and expose theTermobjectOnTermRunningEnd(Term term): Executed at the end of the process for a term and expose theTermobjectOnTermSetRunningEnd(TermSet termSet): Executed at the end of the process for a term set and expose theTermSetobjectOnTermGroupRunningEnd(TermGroup termGroup): Executed at the end of the process for a term group and expose theTermGroupobjectOnTermStoreRunningEnd(TermStore termStore): Executed at the end of the process for a term store and expose theTermStoreobjectOnSiteCollectionRunningStart(Site site, Web rootSite): Executed at the start of the process for a site collection and expose theSiteobject and theWebfor the root siteOnSiteRunningStart(Web web): Executed at the start of the process for a site and expose theWebobjectOnListRunningStart(List list): Executed at the start of the process for a list and expose theListobjectOnFolderRunningStart(Folder folder): Executed at the start of the process for a folder and expose theFolderobjectOnListItemRunningStart(ListItem listItem): Executed at the start of the process for a list item and expose theListItemobjectOnFileRunningStart(File file): Executed at the start of the process for a file and expose theFileobjectOnListRunningEnd(List list): Executed at the end of the process for a list and expose theListobjectOnSiteRunningEnd(Web web): Executed at the end of the process for a site (after the lists) and expose theWebobjectOnSiteRunningEndAfterSubSites(Web web): Executed at the end of the process for a site (after the sub sites) and expose theWebobjectOnSiteCollectionRunningEnd(Site site, Web rootSite): Executed at the end of the process for a site collection and expose theSiteobject and theWebfor the root siteOnTenantRunningEnd(Tenant tenant): Executed at the end of the process for the tenant and expose theTenantobjectOnEnd(): Executed at the very end of the process, can be used to export a file of make an external call
At the moment, the process to use the process is the one which is in the Program.cs from the example.
In the future, I want to have one or many DLLs with contain the receiver and declared in a standard configuration file (XML nor JSON) and call the process with the configuration file (and the DLLs), without any program (but keep the possibility fo doing that way). In addition, I would create PowerShell CmdLets to call the process from a script.
I wrote a few examples from past experiences, availables in examples here
GroupsReceiver: A receiver which export to CSV file the users of groups which contains one of the value (from groupNames) in their nameManagedMetadataReceiver: A receiver which export all the managed metadata from the SharePoint term storePermissionsReceiver: A receiver which crawl every site collection, sub sites and lists (and possibly folders and items) to know if they have inheritance broke and get the users and the permission level grantedWebPartsReceiver: A receiver which crawl every site and sub sites to get all pages (from Site Pages or Pages) and the number of web parts on each oneWebUsageReceiver: A receiver which get the item the most recently item from each site and sub site
These features are mandatory to have a real usable tool for a large panel of use cases
- Create NuGet packages (one with the SDK, one with the process)
- Allow configuration of logs :to console, file, trace
- Complete unit tests
- Several tehcnical improvments
- Separate receivers from the program which call the process to DLL
- Create PowerShell CmdLets to call the process with a standard configuration file (XML nor JSON)
- Others technical improvnents