Monday, February 16, 2015

Web Application : Retrieve All Users Assigned to Groups in Site Collections (SP2010 & SP2013)

Issue:

You are requested to retrieve all users in all groups inside all site collections under a web application.

Solution:

Run this PowerShell script in SharePoint Management Shell

#Header
"SiteCollectionURL;GroupName;PermissionLevel;UserName;UserID"

Try
{
 $WebApplicationUrl = "http://contoso.com" 
 $webApplication = Get-SPWebApplication $WebApplicationUrl -ErrorAction SilentlyContinue;
  
 if($webApplication -ne $null)
 {
  foreach($site in $webApplication.Sites){
   #Get all Site Collection Administrator
   foreach ($siteAdmin in $site.RootWeb.SiteAdministrators)
   {
    $site.URL+";Site Administrator;Full Control;"+$siteAdmin.DisplayName+";"+$siteAdmin.UserLogin
   }
   
   
   $groups = $site.RootWeb.SiteGroups
   foreach ($group in $groups) 
   {
    foreach ($user in $group.users) 
    {
     $site.URL+";"+$group.Name+";"+$group.Roles+";"+$user.DisplayName+";"+$user.UserLogin
    } 
   }
   $site.Dispose()
  }
 }
 else
 {
  Write-Host "Could not find Web Application $WebApplicationUrl" -ForegroundColor Red;
 }
}
Catch [system.exception]
{
 "Error Occurred: $_"
}

Usually I will just simply save the code as in PS1 file and use this command to save it into CSV file.

file.ps1 > result.csv

And then use Excel to massage the data accordingly. Have fun!

For SP2007 solution, click here.

Sunday, February 15, 2015

Search Service Application : Full Crawl Takes Forever to Complete.

Issue:

Search Service Application crawls never completed.


Solution:


  1. Check if there is any warning/error in your SSA Topology.
  2. If any, stop the crawling. Then, reset index. Once reset, check again the topology if the warning/error gone.
    1. If gone, do full crawl again.
    2. If persist, clear SharePoint Cache. You may refer to my earlier post here. Once cleared, reset index again, and the recrawl.
  3. If all steps done but it still takes long time to crawl; perhaps the SSA Index Component is not enough to cater your item. If you estimated number of documents in your SP2013 roughly more than 10k, the default SSA might not enough. You need to add more Index Component.

My web application has more than 1,000,000 documents to be crawled. Using default SSA setting (1 index component) cause my SSA to stuck in crawling for more than 17 days and never progressing. Increasing the Index Component to 4, and move the indexing folder to another Drive, makes my crawling complete within 6 days. (Well even still consider sucks, it is still better than 17 days, isn't it? :P)