Steps
  1. Start your windows PowerShell on your computer.
  2. Right click and select Run as administrator option.
  3. Paste the below script on the PowerShell window and click the enter button.
  4. Check your SharePoint site Feature will activated successfully.
  1. if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)
  2. {
  3. Write-Host "Connect Sharepoint cmd-Let"
  4. Add-PSSnapin Microsoft.SharePoint.PowerShell
  5. }
  6. $url = "http://gauti.sharepoint.com"
  7. $site = new-object Microsoft.SharePoint.SPSite($url)
  8. $web = $site.OpenWeb()
  9. $groups = $web.sitegroups
  10. $userName = "username\Domain"
  11. write-host "--------------"
  12. $i = 0;
  13. $myGroups = @();
  14. foreach($group in $groups) {
  15. if($group -match "admin")
  16. {
  17. $myGroups += $group
  18. }
  19. }
  20. foreach ($gr in $myGroups)
  21. {
  22. write-host $gr
  23. #add user to SP Group
  24. Set-SPUser -Identity $userName -web $url -Group $gr
  25. $theGroup = $web.SiteGroups[$gr]
  26. $theUser = $web.AllUsers.Item($userName)
  27. #Remove user from SP Group
  28. # $theGroup.RemoveUser($theUser);
  29. write-host "User " $userName "added to " $gr
  30. }
Run the script with the required administrator privilege.To verify that, go the group chec user added or not.
Thanks For reading.