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
Hi,
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?
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, 2024
You 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?
- Jul 10, 2024Should be:
$myUsers = Import-Csv -Path 'C:\Users\Salamander\Downloads\UsersToPreProv.csv'
foreach ($user in $myUsers) {
New-PnPPersonalSite -Email $user
}
But what does your csv file look like? When you run this, what do you see and what does $user contain after running?- AB21805Jul 10, 2024Bronze Contributor