Forum Discussion
AB21805
Jul 03, 2024Bronze Contributor
Using powershell to create folders within users onedrive
Hi all, I'm experiencing several issues with different PowerShell versions when trying to create folders in OneDrive for users in bulk. PowerShell 5.1 does not recognize Connect-PnPOnline. Powe...
AB21805
Jul 04, 2024Bronze Contributor
Thanks but the link you provided shows how to create folders within a specifc sharepoint list, my end goal is to create folders within multiple users onedrives.
Jul 04, 2024
Sorry, my bad... Wrong link... But something like this, I guess, https://learn.microsoft.com/en-us/answers/questions/853168/bulk-create-folder-in-onedrive-accounts-using-powe, should work. The most important is to install the pnp.powershell module. You can use that in PS7 too, but I remember that in the past I had to use Import-Module -Name pnp.powershell -UseWindowsPowerShell
- AB21805Jul 04, 2024Bronze ContributorHi,
I have used this script to grant permissions before, but I now need to restrict it to only add permissions to a specific set of OneDrives instead of all OneDrives. I would like to modify the script so that it reads a CSV file to determine which users should have their OneDrive permissions updated.
When the script reaches the folder creation section, I want it to reference the URLs for the OneDrives I granted access to earlier, and create folders only for the users listed in the same CSV file.
How can I adjust the code to achieve this?- Jul 09, 2024You can check before creating directories if the user is in the CSV. What does the CSV look like, and what is your script so far?
- AB21805Jul 10, 2024Bronze Contributor
So I have a list of users I want to retrive the onedrive URLs for and the title is UserPrincipalName (I have also tried "Email"
The code I am using is
$myUsers = Import-Csv -Path 'C:\Users\Salamander\Downloads\UsersToPreProv.csv'
New-PnPPersonalSite -Email $myUsersError:
Any ideas?
- AB21805Jul 09, 2024Bronze Contributor