Import Users from Excel to SharePoint using PowerShell
# Import the .csv file, and specify manually the headers, without column name in the file
$userList=IMPORT-CSV C:\UserToUpload.csv -header("GroupName","UserName")
#Get the site name to the variable
$web = Get-SPWeb SiteURLHere
foreach ($user in $userList)
{
$groupName = $web.SiteGroups[$userList.group]
$user = $web.Site.RootWeb.EnsureUser($userList.user)
$groupName.AddUser($user)
}
Write-Host -ForegroundColor green "Users Added Successfully"
}
$Web.Dispose()
No comments:
Post a Comment