Skip to content

Add sample: remove site collection admins after providing support#971

Open
fabianhutzli wants to merge 1 commit into
pnp:mainfrom
fabianhutzli:remove-sitecollection-admins-after-providing-support
Open

Add sample: remove site collection admins after providing support#971
fabianhutzli wants to merge 1 commit into
pnp:mainfrom
fabianhutzli:remove-sitecollection-admins-after-providing-support

Conversation

@fabianhutzli

Copy link
Copy Markdown
Contributor

Summary

Site collection administrator access granted temporarily to support staff (for tickets/access requests) is often never revoked once the case is closed. This sample provides a two-step, CSV-driven workflow to find and clean up these leftover, directly-assigned site collection admins across a tenant.

Features

  • Loops through every site collection in the tenant and checks its site collection administrators against a known list of support/admin accounts ($Administrators)
  • Only considers directly assigned site collection administrators, not group/team owners or other inherited roles
  • Exports matches to SitesSCAdmin.csv with an empty Remove column for manual review
  • On a follow-up run, imports the reviewed SitesSCAdmin_cleanup.csv, filters for rows flagged x in the Remove column, and removes those site collection administrators
  • Includes a tip recommending non-interactive authentication (certificate/client secret) instead of -Interactive for regular/unattended runs

Script type

PnP PowerShell

Author

Fabian Hutzli

Adds a PnP PowerShell script sample that reports directly-assigned
site collection administrators matching known support/admin accounts
across the tenant, and removes them once flagged for cleanup in a
follow-up CSV-driven run.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant