As part of deploying Sharepoint 2010 intranet for a large EPC in India, the clients IT administrator came up with a request for a utility to add users from active directory to Sharepoint 2010 user groups. They wanted this utility because they had more than 1000 users and adding users manually was a pain.

We quickly developed a power shell script that gets the active directory department and Sharepoint user group as parameters and adds all the users within the department to the Sharepoint group. This script saved lot of time for IT  administrator. Below is the snippet of the script that adds users to Sharepoint  group



$site = New-Object Microsoft.SharePoint.SPSite($siteInp);

$groups = $site.openweb()


$groups.SiteGroups[$groupInp].AddUser($domainInp+"\"+$objItem.samaccountname , $objItem.mail