I've created 2 scripts, one to export SharePoint Online permissions to a .CSV and one to re-provision SharePoint Online access.
I've come across a slight problem which is preventing the script from running successfully, the script to export SharePoint permissions lists the groups within one cell. When the re-provision script reads the input file (.csv) it errors because the script can't seem to read multiple values within the same cell.
Here's an example input:
https://TEST.sharepoint.com [email protected] Test Group 1 Test Group 2 Test Group 3
I've also tried separating the groups via special characters but this doesn't work either:
Test Group 1, Test Group 2, Test Group 3
This is my re-provision script so far:
Write-Host "---Start of Script $(Get-Date)"
Connect-SPOService -URL https://******-admin.sharepoint.com -credential *****@*****
$SPOUserImport = Import-csv "PATH"
foreach($ImportData in $SPOUserImport)
{
$field1 = $ImportData.Group
$field2 = $ImportData.Site
$field3 = $ImportData.User
Add-SPOUser -Group $field1 -Site $field2 -LoginName $field3 |Out-Null
Write-Host "Added $field3 from .CSV to $field1, $field2" -ForegroundColor Green
}
Write-Host "---End of Script $(Get-Date)"
Any help appreciated!
Callum