Thursday, June 13, 2013

Configure SharePoint 2010 Service application using Powershell

Below script will create services for office web apps

Word Viewing Service Application
Excel Service Application
PowerPoint Service Application

Save this file as .ps1 in your local server folder.
Open SharePoint 2010 Management Shell> create dir local folder path and run it

$saAppPoolName = "SharePoint Web Services"
$saAppPool = Get-SPServiceApplicationPool -Identity $saAppPoolName -EA 0
if($saAppPool -eq $null)
{
  Write-Host "Creating Service Application Pool..."
 
  $appPoolAccount = Get-SPManagedAccount -Identity $appPoolUserName -EA 0
  if($appPoolAccount -eq $null)
  {
      Write-Host "Please supply the password for the Service Account..."
      $appPoolCred = Get-Credential $appPoolUserName
      $appPoolAccount = New-SPManagedAccount -Credential $appPoolCred -EA 0
  }
 
  $appPoolAccount = Get-SPManagedAccount -Identity $appPoolUserName -EA 0
 
  if($appPoolAccount -eq $null)
  {
    Write-Host "Cannot create or find the managed account $appPoolUserName, please ensure the account exists."
    Exit -1
  }
 
  New-SPServiceApplicationPool -Name $saAppPoolName -Account $appPoolAccount -EA 0 > $null
     
}
 
Write-Host "Creating Service and Proxy..."
$appPool = Get-SPServiceApplicationPool -Identity "SharePoint Web Services"
New-SPWordViewingServiceApplication -Name "Word Viewing Service Application" -ApplicationPool $appPool | New-SPWordViewingServiceApplicationProxy -Name "Word Viewing Service Application"
New-SPPowerPointServiceApplication -Name "PowerPoint Service Application" -ApplicationPool $appPool | New-SPPowerPointServiceApplicationProxy -Name "PowerPoint Service Application" -AddToDefaultGroup
New-SPExcelServiceApplication -Name "Excel Service Application" -ApplicationPool $appPool

Please see below link for more information

System.ArgumentException: Exception of type 'System.ArgumentException' was thrown. Parameter name: encodedValue at Microsoft.SharePoint.Administration.Claims.SPClaimEncodingManager.DecodeClaimFromFormsSuffix(String encodedValue)

When you are working with SharePoint FBA controls like 

<asp:ChangePassword
 <asp:PasswordRecovery

you will get below error.

System.ArgumentException: Exception of type 'System.ArgumentException' was thrown.  Parameter name: encodedValue  
 at Microsoft.SharePoint.Administration.Claims.SPClaimEncodingManager.DecodeClaimFromFormsSuffix(String encodedValue)   
 at Microsoft.SharePoint.Administration.Claims.SPClaimProviderManager.GetProviderUserKey(String encodedSuffix)   
 at Microsoft.SharePoint.SPGlobal.CreateSPRequestAndSetIdentity(SPSite site, String name, Boolean bNotGlobalAdminCode, String strUrl, Boolean bNotAddToContext, Byte[] UserToken, String userName, Boolean bIgnoreTokenTimeout, Boolean bAsAnonymous)   
 at Microsoft.SharePoint.SPWeb.InitializeSPRequest()   
 at Microsoft.SharePoint.WebControls.SPControl.EnsureSPWebRequest(SPWeb web)   
 at Microsoft.SharePoint.WebControls.SPControl.SPWebEnsureSPControl(HttpContext context)   
 at Microsoft.SharePoint.ApplicationRuntime.BaseApplication.Application_PreRequestHandlerExecute(Object sender, EventArgs e)   
 at Microsoft.SharePoint.ApplicationRuntime.SPRequestModule.PreRequestExecuteAppHandler(Object oSender, EventArgs ea)   
 at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()   
 at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

There are many reasons to get this error.
1)      Make sure all the properties or attributes are correct for the control.
2)      Sometimes if you are working with forgot password or change password you can see the error. Cookies might create a problem as we are not logged in to change password.
3)      Add this attribute in the control MembershipProvider="giveyourmembershipname"
.CS FILE
public partial class ChangePassword : UnsecuredLayoutsPageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected override bool AllowAnonymousAccess
        {
            get
            {
                return true;
            }
        }



        protected void myPasswordChanged(object sender, EventArgs e)
        {
            if (Request.Cookies[".ASPXAUTH"] != null)
            {
                HttpCookie myCookie = new HttpCookie(".ASPXAUTH");
                myCookie.Expires = DateTime.Now.AddDays(-1d);
//myCookie.Path = ApplicationName();
                Response.Cookies.Add(myCookie);
                Response.Write("surya");
            }
        }

        //ContinueDestinationPageUrl="~/_layouts/DAIDS_RSC/SignIn.aspx"
    }

ASPX page
  <asp:ChangePassword ID="ChangePassword1" runat="server" MembershipProvider="RSCMemberProvider" OnChangedPassword="myPasswordChanged"
                 DisplayUserName="true" InstructionText="Enter your username and old password."
                 ContinueDestinationPageUrl="~/_layouts/DAIDS_RSC/SignIn.aspx"
                 CancelDestinationPageUrl="~/_layouts/DAIDS_RSC/SignIn.aspx"
                 >



Thursday, May 23, 2013

Remove providername of FBA user name in sharepoint 2010


#[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
#Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
#add-pssnapin Microsoft.SharePoint.Powershell

<#
  Users.csv has list of all user names.

UserName
Suryap
Ravik
Johnp

#>

Copy below code and save it as .ps1 file. Open PowerShell window, run below script.
It will remove provider name from FBA user name.


$InputFile = "d:\surya\Users.csv"
$URL= "http://spdev5:8003"
$site = New-Object Microsoft.SharePoint.SPSite($URL)
$web = $site.openweb("")
$file = ipcsv $InputFile
$i = 1

#variables
      $fbaUserName= $null
      $fbaformattedlogin = $null
     
      foreach ($line in $file)
      {
            $fbaUserName = $line.UserName  #.csv file column name  

# update 'scmemberprovider' with your provider name

          $fbaformattedlogin = "i:0#.f|scmemberprovider|" + $fbaUserName   
          Set-SPUser $fbaformattedlogin -Web $URL -DisplayName $fbaUserName
          #Get-SPUser $fbaformattedlogin -Web $URL
           
           # $i++
           # if($i -eq 4)
          #{
           #       break;
          #}
      }          
$web.Dispose()
$site.Dispose()
     

SharePoint 2010 Service Pack1 Instllation Steps

here is the document..

https://docs.google.com/file/d/0B_OpLHHlwhiRZlRnbGphbDJweDQ/edit?usp=sharing


missing office web apps server components in a farm SharePoint 2010

Error: Some farm products and patches were not detected on this or other servers. If products or patches are missing locally, you must quit this program and install the required products and patches on this server before restarting this wizard. if products or patches are missing on other server, you must install required products and patches on specific server.

To fix this error follow below steps.

here you can see all servers patches and which server is throwing errors 

Central Admin > Upgrade and Migration > Check product and patch installation status

in this situation some times you cannot open Central Admin then check below 

1) Check all application pools are running. If not start the pools 
2)Check Web Services Site running
2) IIS server > SharePoint Central adminstation site > right click start

sometimes you might get error w3svc not running. in this case 

IIS manager > Select sites >you can see right side Action menu > start 

now you can open Central admin site.

let's say you have app1 app2 web1 web2 servers in your farm. If app2 have any errors..

Run below Powershell command

Get-SPProduct -Local

Now run the configuration wizard. It will fix your problem.

still if you have any issues run the above command in all servers.



Friday, May 17, 2013

Restore-SPSite : The content type text/html; charset=utf-8 of the response mess age does not match the content type of the binding (application/soap+msbin1). I f using a custom encoder, be sure that the IsContentTypeSupported method is imp lemented properly


I got this while restoring SharePoint 2010 site. After lot of efforts I have found something wrong in my web.config files.

Make sure all nodes are implemented properly in the web.config files especially when you are working with forms based configuration. 

if you have any duplicate nodes or spaces it might get this error.

Check below web.config files 

1) Central administration
2) Your Web App
3) 14\Security Token\Web.Config


for ex,


<connectionStrings>
      <add name="SQLConnectionString" connectionString="server=servername;UID=webuser;PWD=1230;database=UsersDB; connection reset=false; enlist=true; min pool size=1; max pool size=125" providerName="System.Data.SqlClient" />
</connectionStrings>


<membership defaultProvider="i">
      <providers>
        <add name="i" type="Microsoft.SharePoint.Administration.Claims.SPClaimsAuthMembershipProvider, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
        <<add connectionStringName="SQLConnectionString" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" passwordAttemptWindow="10" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" name="myMemberProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

      </providers>
    </membership>
    <roleManager defaultProvider="c" enabled="true" cacheRolesInCookie="false">
      <providers>
        <add name="c" type="Microsoft.SharePoint.Administration.Claims.SPClaimsAuthRoleProvider, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
  <add connectionStringName="SQLConnectionString" applicationName="/" name="myRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0,Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />      </providers>
    </roleManager>





Thursday, May 2, 2013

Crawl everything under the hostname for each start address VS Only crawl the Site Collection of each start address

for more details go through below post regarding sharepoint 2010 search
http://suryapulipati.blogspot.com/2013/04/sharepoint-2010-search-and-scopes.html


http://spdev5:8004/ (root site collection)



Crawl everything under the hostname for each start address

 

Only crawl the Site Collection of each start address

You can go for this option, If you want to enable search for all site collections under one web app.

If you want to enable search for only one specific site collection
You have to create a scope to filter sitecol2 and 3 results in the root site collection.
You don’t need to create scopes If you are crawling only one site.
It will crawl all site collections under this site when add to the content source. You can use “Local SharePoint Sites”.


It crawls only root site collection not all site collections like sitecol2 and 3. You have to create custom content source

To filter results in the root site collection, you have to write rules in the scopes like this.

Include
Exclude (Sitecol2)
Exclude (Sitecol3)

No scopes needed.

Include

Create custom page in the root site collection and add “core results web part” to this page. Enter scope name in the web part scope property.
No need of custom page unless you are crawling more site collections.

In future if you want to enable search for sitecol2 or 3 you have to add the site to custom Content source.

When you crawl this site, you can see site collection2 documents in the root site collection search results (if you  have permissions on site2 or 3).
Now scopes will come into the picture again.

Include
Exclude (Sitecol2)
Exclude (Sitecol3)


So when you want to go for enable search for multiple site collections under one web app, better option is “Crawl everything under the hostname for each start address”


Followers