1

I have aa Excel sheet which have multiple site collection sites (around 600) of same web application. I want to add a user with full control rights on all the site collections from Excel sheet.

My Excel sheet example:

http://example.com/aa/bb
http://example.com/cc/dd

Please suggest how can I automate it with PowerShell script or by using C# code.

0

If this is for SharePoint Online, then the easiest and only CSOM-free way would be

foreach($site in $sites){set-spouser -Site $site -LoginName user@domain.com -IsSiteCollectionAdmin $true}

Admin is not the same as Full Control, but does not require CSOM.

If this is SharePoint on prem, then use this:

$csv=import-csv C:\Users\Administrator\Desktop\stack.csv
foreach($site in $csv){Set-SPUser -Identity 'i:0#.w|spo\devuser' -Web $site.Site -AddPermissionLevel "Full Control"}

Documentation: https://technet.microsoft.com/en-us/library/ff607827.aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.