0

I need to create Azure AD users in bulk (about 90), in order to add each of them:

  • To a SharePoint group present in 90 sub-sites
  • Authorizations from two libraries in each of these sub-sites

Example :

  • User: "user1@mydomain.com"
  • SharePoint sub-site: "https://mydomain.sharepoint.com/sites/principalsite/sub-site1" (already created)
  • Two document libraries: "Library1" and "Library2" (already created) for which the user "user1@mydomain.com" must be added to the authorizations of these two libraries, with a specific authorization level "Special authorization" (already created)


  • User: "user2@mydomain.com"

  • SharePoint sub-site: "https://mydomain.sharepoint.com/sites/principalsite/sub-site2" (already created)
  • Two document libraries: "Library1" and "Library2" (already created) for which the user "user2@mydomain.com" must be added to the authorizations of these two libraries, with a specific authorization level "Special authorization" (already created)

Etc Etc Etc..... Up to 90.

The idea would be to create a PowerShel script based on a CSV file with the necessary information: UPN > Sharepoint link > Sharepoint group name > Document library names > Name of the specific authorization level.

I don't really master scripting and I don't know much about the powershell functions related to Sharepoint. After some research, I find information but it doesn't really correspond to my needs.

Can you help me ?

Regards,

  • Hello, I share my research : Mass creation of Azura AD users: $users = Import-Csv C:\O365_EA_Users.csv $users | ForEach-Object { New-MsolUser -UserPrincipalName $_.UserPrincipalName -DisplayName $_.DisplayName -FirstName $_.FirstName -LastName $_.LastName -Password $_.Password } Adding these users to the "Visitors" groups of each sub-site: $users = Import-Csv C:\O365_EA_UsersToGroupSP_2.csv $users | ForEach-Object { Add-SPOUser - Site $_.Subsite -LoginName $_.UserPrincipalName -Group $_.Group } Anyone to help me add users to document library permissions ? – NonoCHÉ May 21 at 14:37
0

Looks like you can already create the users and add them to groups, why not create a group in the permissions for each document library with the "Special auth" permissions level, and add the user to that group?

0

Having integrated users into the visitor group of each sub-site, I ended up adding this group to the permissions of the two document libraries of each sub-site (there is obviously no powershell function to add users, only groups, and thinking about it, it is wise to proceed like that for future evolution in permissions)

$group = Import-Csv C:\O365_EA_GrouptoPermissionList.csv

$group | ForEach-Object {
Connect-PnPOnline $_.url -Credential $userCred;
Set-PnPGroupPermissions -identity $_.groupname -List $_.library1 -AddRole "MySpecialPermission";
Set-PnPGroupPermissions -identity $_.groupname -List $_.library2 -AddRole "MySpecialPermission"
 }

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.