Giter VIP home page Giter VIP logo

sp-permissions-audit's Introduction

SharePoint Online Permissions Audit Script

It is well known that SharePoint permissions are notoriously difficult to manage. This script is designed to help you audit permissions across your SharePoint Online sites.

โœจ Features

  • Audit permissions for all sites in a SharePoint Online tenant - all the way down to list and library level.
  • Capture permissions granted to Security (Entra ID) and Microsoft 365 groups.
  • Uses a modern authentication flow that does not require a user to be logged in or have access to all sites in the tenant.

๐Ÿ“ Output

The script will output a CSV file with the following columns:

Column Name Description
UserPrincipalName The user's UPN/email address
SiteUrl The URL of the site
SiteAdmin Is the user a site admin?
GroupName If the user is not a site admin, what SharePoint group are they in? (also captures sharing links)
PermissionLevel The permission level granted to the SharePoint group, e.g full control, read, edit etc.
ListName The title of a list or library where the user has unique permissions.
ListPermission The permission level granted to the user on the list or library.

๐Ÿš€ Getting Started

Prerequisites

  • Global Adminstrator Role
  • PowerShell 7 or later with the latest versions of PnP.PowerShell and MSAL.PS modules installed.
  • A self-signed certificate for use with the app registration. See this article for more information.
Install-Module -Name PnP.PowerShell -Scope CurrentUser
Install-Module -Name MSAL.PS -Scope CurrentUser

Create an Entra ID App Registration

Follow the steps in this article to create an app registration in Azure AD. Make sure you grant the app the following permissions.

Graph API

  • Sites.Read.All
  • Directory.Read.All

SharePoint API

  • Sites.FullControl.All
  • User.Read.All

Usage

The intention is for this script to be called by a parent script that will pass in the required parameters. This allows you to run the script against multiple users and potentially multiple tenants. Below is an example of how you might call the script.

# audit.ps1 - Create in the same directory as Get-SharePointOnlinePermissions.ps1

$tenantName = "contoso" # The name of your tenant, e.g. contoso.sharepoint.com
$csvPath = "C:\temp\permissions.csv" # The path to the output CSV file
$clientID = "00000000-0000-0000-0000-000000000000" # The client ID of the app registration
$certificatePath = "C:\temp\certificate.pfx" # The path to the certificate file
$append = $true # Should the script append to the CSV file or overwrite it?

$users = @(
    "[email protected]",
    "[email protected]"
)

foreach ($user in $users) {
    .\Get-SharePointOnlinePermissions.ps1 -TenantName $tenantName -CsvPath $csvPath -ClientID $clientID -CertificatePath $certificatePath -Append:$append -UserEmail $user
}

๐Ÿค Contributing

Contributions, issues and feature requests are welcome!

TODO:

  • Replace MSAL.PS cmdlets with a non-deprecated alternative

sp-permissions-audit's People

Contributors

scottmckendry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.