Create SharePoint Groups in Bulk using CSV file
Summary
This script shows how to create multiple groups in SharePoint for different site collection providing input from CSV file.
Implementation
- Open Windows PowerShell ISE
- Create a new file
- Write a script as below,
- Create a CSV using the provided sample. Two columns are required SharePointUrl and SharePointGroupName
- Then we provide the path of the file as input to the PowerShell when prompted in the window when executed.
Download Sample CSV from this link
Execution Image and output Image
#Uncomment below line if facing remote server 400 error
#Import-Module SharePointPnPPowerShellOnline -UseWindowsPowerShell
$filePath = Read-Host "Please provide CSV file path"
# Import CSV file from given path
$importedFile = Import-Csv -Path $filePath
for ($index = 0; $index -lt $importedFile.Count; $index++) {
# Connect to SharePoint online site
Connect-PnPOnline -Url $importedFile[$index].SharePointUrl -Interactive
# Create a new group in SharePoint site
New-PnPGroup -Title $importedFile[$index].SharePointGroupName
}
Check out the PnP PowerShell to learn more at: https://aka.ms/pnp/powershell
The way you login into PnP PowerShell has changed please read PnP Management Shell EntraID app is deleted : what should I do ?
Contributors
Author(s) |
---|
Kunj Sangani |
Ganesh Sanap |
Disclaimer
THESE SAMPLES ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.