We are in a very large tenant migration project, and are migrating 8000 users from one Tenant to another. We have to reset permissions on SharePoint sites for the users. We have a permissions audit spreadsheet that lists out the users email, the SiteURL, their permissions to the site, whether from a group or individually, and then what level of access. The goal here is to use a CSV file, due the number of users. I am able to script out adding the users to the groups.
Import-Csv C:\MigrationFiles\UserstoGroups.csv | ForEach {Add-SPOUser -Group $.Group -LoginName $.LoginName -Site $_.Site}
This works fine. However I am struggling doing individual permissions via a CSV import. I can do the commands individually:
Connect-PNPOnline -URL (https://contso.sharepoint.com) -Interactive
Set-PNPWebPermissions -User @contso.com -Add Role "Contribute"
The problem I am having now is trying get this formatted to pull in multiple lines via a CSV file. My input file is as such:
|URL User |Role|||
| -------- | -------- | -------- | -------- |
|https://contso.sharepoint.com/sites/Site1|@contso.com|Full Control||
|https://contoso.sharepoint.com/sites/Site4|@contso.com|Contribute||
|https://contso.sharepoint.com/sites/Site2|@contso.com|Read| |
Could someone help me with the correct syntax on the ForEach to run through the Connect PNPOnline and Set-PNPWebPermissions as two commands, reading each row? I am truly stuck here.