Press "Enter" to skip to content

Automate SharePoint App Installation Across Multiple SharePoint Sites

When one of our customers purchases the Encodian PDF Converter for SharePoint Online one of the first questions they ask is how do the automate the deployment of a SharePoint app to multiple sites and webs within their SharePoint Online tenancy. As this was a common requirement we’ve produced a set of PowerShell scripts to enable you to do just that.

NOTE: These scripts are configurable so will work to automate the deployment of any SharePoint app within a SharePoint Online tenancy.

The steps in this article assume that your SharePoint Online tenancy has an App Catalog site and that the ‘Encodian PDF Converter for SharePoint Online’ application package or the application package that you want to deploy has been added to the App Catalog. 

To create the SharePoint App Catalog follow steps 1 & 2 in this Microsoft support article and then add the application package that you want to deploy.

The ‘Encodian PDF Converter for SharePoint Online application package’ can be downloaded here.

Attached to this article are two PowerShell scripts, please note the file extension of the scripts will need changing to ps1

  • EncodianGetAppSites.ps1 is used to create a .csv file containing all site collections and sub-sites within your tenancy.
  • EncodianDeployApp.ps1 uses the .csv output of the first script to determine which sites and sub-sites to deploy the app to.

Prerequisites

In order to execute these scripts in Windows PowerShell the following packages are required

Windows Management Framework 5.1

SharePointPnPPowerShellOnline

Obtain All Sites / Webs in your Tenant

Open EncodianGetAppSites.ps1 and set values for the following parameters:

  • $orgName  – this is the SPOnline organisation name as used in the URL of the SharePoint online administration site e.g. https://$orgName-admin.sharepoint.com
  • $filePath – this is the folder location where the generated .csv file will be stored, e.g. “C:\Temp\”
  • $fileName – this is the name of the .csv file, e.g. “deploy.csv”

Once updated, execute EncodianGetAppSites.ps1. The user will be prompted for credentials which will require tenant administration rights to execute successfully.

The generated .csv will contain the Name and URL of all sites and sub-sites alongside a Status column.  To install the app in a site or sites enter the word “New” in the status column for that site.

Entries within the csv file can be amended, deleted or new entries added as required.

Install the Application

Open EncodianDeployApp.ps1 and set values for the following parameters, which should be the same values as those set in the first script

  • $orgName  – this is the SPOnline organisation name as used in the URL of the SharePoint online administration site e.g. https://$orgName-admin.sharepoint.com
  • $filePath – this is the folder location where the .csv generated by the first script is stored
  • $fileName – this is the name of the .csv file, e.g. “deploy.csv”

Once updated, execute EncodianDeployApp.ps1 and the app will be installed to the sites indicated by the “New” status in the .csv.

Please note if the same csv file is used for subsequent installations, the “New” status should be removed from sites where the app has already been installed

Be First to Comment

Leave a Reply

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