Git Product home page Git Product logo

spo-set-versions's Introduction

spo-set-versions

PowerShell script to Major and Minor versions across SharePoint sites and remove out-of-date versions

This script can run in one of two modes

  1. What If - Non destructive dry run, will report on potential space savings
  2. Delete Old Versions - Same as above but will actually delete versions in SharePoint

Creating a Certificate

  1. Edit the CreateSelfSignedCert.ps1 file.
  2. Replace {certificateName} with something like SharePoint Version Control.
  3. Navigate to directory in PowerShell and run ./CreateSelfSignedCert.ps1
  4. Make a note of the random string that gets output (the Thumbprint).

How to setup as an Azure app

  1. Sign in to the Azure portal
  2. Navigate to App Registrations
  3. New Registration
  • Name your app something like "Sharepoint Version Control"

  • Select the correct account type (normally Single Tenant)

  • Leave Redirect URL empty

  • Click Register

  • Make note of the Application (client) ID

  • Make note of the Directory (tenant) ID

  • Click "View API permissions"

Sharepoint Version Control | API permissions

  • Click Add a permission
  • Click the Sharepoint block
  • Click Application permissions
  • Check 'Sites.FullControl.All' or 'Sites.Selected' if you only want to look at one SharePoint Site
  • Click Add permissions button
  • You should see your new permission for SharePoint Listed
  • Click 'Grant admin consent' Successful Permission!

Upload Certificate

  • upload it

ParametersVersions.json (the config)

How to setup the config file
  1. Replace the TenantID Value with the Directory (tenant) ID you noted down in the stage above (line 3).
  2. Replace the clientId Value with the Application (client) ID you noted down in the stage above (line 6).
  3. Replace the thumbprint Value with the Thumbprint string you noted down in step 4 of Creating a Certificate (line 11).
  4. Change majorVersionCount to the number of major version you want to keep, or leave at the default value (line 19)
  5. Change minorVersionCount to the number of minor version you want to keep, or leave at the default value (line 22)
  6. Change whatIfMode Value to true
  7. Change deleteOldMajorVersions Value to false

Steps 4 and 5 are WELL worth double checking, probably best to do a try run first before deleting all your files!

SitesToProcess.csv

This file holds the SharePoint URLs for the sites you want to process.

Powershell

  1. Install PNP module (used so PowerShell can talk to Sharepoint) Install-Module -Name PnP.PowerShell
  2. Make sure PowerShell has script execution permissions, follow instructions here.

spo-set-versions's People

Contributors

groveale avatar thickey256 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.