Created
June 1, 2021 12:02
-
-
Save waldekmastykarz/82846388f8b88176f63f73d2f1f0256f to your computer and use it in GitHub Desktop.
Removes granted SharePoint API permissions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env zx | |
| $.verbose = false; | |
| console.log('Retrieving granted API permissions...'); | |
| const apiPermissions = JSON.parse(await $`m365 spo sp grant list -o json`); | |
| for (let i = 0; i < apiPermissions.length; i++) { | |
| const permission = apiPermissions[i]; | |
| console.log(`Removing permission ${permission.Resource}/${permission.Scope} (${permission.ObjectId})...`); | |
| try { | |
| await $`m365 spo serviceprincipal grant revoke --grantId ${permission.ObjectId}` | |
| console.log(chalk.green('DONE')); | |
| } | |
| catch (err) { | |
| console.error(err.stderr); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment