Skip to content

Instantly share code, notes, and snippets.

@waldekmastykarz
Last active June 1, 2021 12:01
Show Gist options
  • Save waldekmastykarz/e937172b270bcb84e86694012cfa0057 to your computer and use it in GitHub Desktop.
Save waldekmastykarz/e937172b270bcb84e86694012cfa0057 to your computer and use it in GitHub Desktop.
Removes all pending SharePoint API permission requests
#!/usr/bin/env zx
$.verbose = false;
console.log('Retrieving permission requests...');
const permissionRequests = JSON.parse(await $`m365 spo sp permissionrequest list -o json`);
for (let i = 0; i < permissionRequests.length; i++) {
const request = permissionRequests[i];
console.log(`Removing request ${request.Resource}/${request.Scope} (${request.Id})...`);
try {
await $`m365 spo sp permissionrequest deny --requestId ${request.Id}`
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