Want to automate installing apps to SharePoint? Well, you’re in the right place!
When one of our customers purchases the Encodian PDF Converter for SharePoint Online, one of the first questions they ask is how to automate a SharePoint app’s deployment to multiple sites and webs within their SharePoint Online tenancy. As this was a standard requirement, we’ve produced a set of PowerShell scripts to enable you to do just that.
NOTE: These scripts are configurable, so they 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 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 add the application package you want to deploy.
You can also download the ‘Encodian PDF Converter for SharePoint Online application package‘.
Attached to this article are two PowerShell scripts. Please note the file extension of the scripts will need to change 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
To execute these scripts in Windows PowerShell, the following packages are required.
Windows Management Framework 5.1
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 requiring 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 on 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 specified 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.