Posts

Creating SharePoint Aspx Pages from Word Documents using PowerShell

Recently I worked on a solution that converts word documents to web pages in SharePoint, and I think it will be useful for a lot of people, particularly administrators who are looking for a way to convert existing word documents to web pages in SharePoint without having to do copy and paste and worry about how to format the text on the page. So I decided to make it available as a PowerShell script module that you can import and run with a single line of command.
This will be useful for organizations looking to make some documents available in read-only for their employees but wants to prevent them from downloading such documents, e.g policy documents may fall in this category. Aside using tools like right management system, one thing you may want to do is converting such documents to web pages. If this sounds like what you want, this PowerShell module is for you. 
To get started, download or clone the project file in GiHub. If you download it as a zip file, unzip it and copy the fold…

Export SharePoint Document Library Metadata Information to PDF Using Power Automate

Image
Finally, I have some time in my schedule to resume blogging after a long break! This post is prompted by someone who recently asked how to export metadata information from a library (form library to be specific) to PDF, in a PowerApps group I belong to. I thought this could be achieved in Power Automate by calling MS graph API but it turns out to be simpler with Word Online (Business) actions. I decided to blog about how I did it to help someone out there who might be looking to do the same thing. So let’s get started! We are going to use content controls. So Open an empty word document and enable Developer tab if you don’t already have it enabled ( note you can enable Developer Tab using Customize the Ribbon..). Once you have enabled th tab, under the Controls section you can add content controls into your document. Use the control Properties to give the control a friendly name that you will use in the Flow. In our own case, we are going to use Repeating Section Content Control insi…

A Simple Way To Re-use Your Existing Script Editor's customization in SPFx Web Part

Image
When migrating to SharePoint modern experience, one of the questions you will be faced with is how to replace your existing Script Editor customizations  with the new SharePoint Framework since scripting is not allowed in the modern sites, meaning Script Editor web part is not available for use (note: you can enable it if you want but it is not recommended). This may leave you thinking about if you have to go learn TypeScript/React, how long it will take and, if and how you can re-use your existing scripts within SPFx. Well, let me tell you the good news, yes you can re-use your existing scripts and it is simple. But it is recommended that you re-write them in TypeScript/React if budget and time permit. So if your goal is re-using the existing scripts as much as possible in the short term while you learn the new language this post is for you.

This post will explain the general steps to re-using your existing script within an SPFx web part but you may need to make some changes to the …

Automate Removal of Orphan Users from SharePoint Online Using CSOM

If you had just migrated to SharePoint Online, one of the few things you will notice is that removing  a user from Azure Active Directory (AAD) does not automatically remove the user from SharePoint sites. This is by design, it is not a bug. This is to ensure that documents uploaded or created by those users are kept with their names in "Created By" field. So after removing them from AAD you have to go to each site the users have access to and manually remove them. But this poses a huge maintenance problem as you can't possibly keep up with this repetitive task, and even  knowing all the sites the user has access to poses a greater challenge. The best solution is to write a daemon application to handle such task.

If you already find yourself in this situation and need a solution, just copy and paste the code below in a console application:

We need to loop through a list of all AAD users and compare them with users in our SharePoint site collections. To get this list, ad…

Custom Theme Applicator for SharePoint Online Modern Experience

Image
In most cases you have to customize the modern experience based on your organization's branding or identity. Microsoft has given us a variety of options to do that; we have PowerShell cmdlets, CSOM and REST API. It seems most people prefer to just use PowerShell for this purpose as you get to see most blogs discussing how to create a custom theme using PowerShell. But to me, it's very tedious to work with PowerShell when you are testing different shades of color to use in your custom theme.  I prefer an interface that allows me to click buttons to create or update, retrieve an existing theme and even remove it without working with a set of commands. It's a faster for me :). So to avoid the hassle of working with commands each time I want to test my theme, I decided to develop a SharePoint add-in  using SharePoint theming REST API . You can download the app here in the app.publish folder. Once downloaded, upload the app to your App catalog and it's ready for use! Here i…

Generate Word Document From A SharePoint List Item Using Microsoft Flow

Image
Recently I took a deep dive into Microsoft flow, and the first task I gave myself was using MS flow for one of the projects I have done in the past. In my former company I was tasked by the legal team to develop a solution that auto-generates contract document based on a predefined template and route it for approval. They wanted to standardized the document so that any contract document leaving the bank to the customers will have the same format. I did this without writing a single line of code, using SharePoint Designer Workflow, List and InfoPath I was able to meet their requirements.

Initially doing this in MS flow seemed impossible, but because MS flow has an action that supports REST APIs I was determined to code it if required. But it turns out to be simpler than it seemed. I used a REST API to achieve it though, but later discovered an action that saved me the two steps introduced by the REST API. I will cover the two methods in this post.

We will start by creating a content t…