How to import users from CSV to SharePoint site using PowerShell

Here we are showing how to import users from csv to SharePoint site using PowerShell, In some cases we have users available in the document or in notepad, we have to add those users into SharePoint group, adding 2 or 3 users manually is not a problem but adding 50+ users it will take lot of effort for a user to add in to SharePoint site.

For this using PowerShell we can add it easily, check the below code snippet and excel with CSV format looks.

Add-PSSnapin Microsoft.SharePoint.PowerShell
$UserinfoCSV = "C:\DotNetSharePoint\ImportUsers.csv"
 # Import the CSV file
#In CSV there are no headers,CSV having two columns values  one is SP group name and another one is username.
$UserInfo = Import-CSV $UserinfoCSV -header("GroupName","UserAccount")
#Get the Web
$Web = Get-SPWeb
 #looping each user from CSV file
foreach ($user in $UserInfo)
       $Group = $web.SiteGroups[$User.GroupName]
    $User = $web.Site.RootWeb.EnsureUser($User.UserAccount)

SharePoint Online Real Time Training Contact: JLAKSHMITULASI@GMAIL.COM

Lakshmi Tulasi Jasti

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment


  1. Developed by Intuit, it is used to write user's financial data into a text format. excel dashboard software