Thursday, April 14, 2016

How to create a Web Application with Classic Authentication in SharePoint 2013

As we all SharePoint developer knows, Microsoft didn't provide a UI interface to create a Classic Authentication Web Application in SharePoint 2013.

But you can create a Classic Authentication Web Application by using powershell command, mostly this kind of practices are used during the migration of SharePoint from old version to SharePoint 2013.


==================
Powershell Command
==================

New-SPWebApplication -Name "SharePoint - 80" -ApplicationPool "SharePoint - 80" -ApplicationPoolAccount (Get-SPManagedAccount "Contoso\SPAdmin") -DatabaseName "WSS_Content" -Port 80 -URL http://myportal/


How to download a wsp file from Central Admin

You can easily download either one wsp file from central admin or you can download all wsp files by using powershell command in Sharepoint 2010 and 2013 environment.

============================
Download one wsp file
============================

$myFarm = Get-SPFarm
$myWSP = $myFarm.Solutions.Item("helloworld.wsp").SolutionFile
$myWSP.SaveAs("C:\helloworld.wsp")

============================
Download all wsp files
============================

$pathName = "c:\wspFiles\"

foreach ($solution in Get-SPSolution)
{
    $solid = $Solution.SolutionID
    $title = $Solution.Name
    $filename = $Solution.SolutionFile.Name
    $solution.SolutionFile.SaveAs("$pathName\$filename")
}

Useful Powershell Commands of SharePoint 2013

These are the following powershell commands which is commonly used during development, Farm Creation and for Administration:

===========================
Backup & Restore
===========================

Backup-SPSite -Identity http://ServerName:port -Path "c:\backup\file.bak"

Restore-SPSite -Identity http://Servername:port -Path "c:\backup\file.bak" -force

===========================
Add and Install WSP
===========================

Add-SPSolution c:\helloworld.wsp

Install-SPSolution –Identity helloworld.wsp -GACDeployment -force -WebApplication http://portal

===========================
Remove WSP
===========================

Remove-SPSolution -Identity helloworld.wsp

===========================
Update WSP
===========================

Update-SPSolution -Identity helloworld.wsp -LiteralPath C:\helloworld.wsp -GACDeployment

How to enable Ajax Functionality on Custom Master Page in SharePoint 2013

When you create a custom master page through design manager in SharePoint 2013, then unfortunately design manager does not add Ajax snippets in this page, and due to this you cannot apply Ajax functionality on your custom web part.

This is not a big deal now, you can just add below mentioned snippets in your custom master HTML page under a body tag and the same tag will be remove from Head.

<!--SPM:<asp:ScriptManager id="ScriptManager" runat="server" EnablePageMethods="false" EnablePartialRendering="true" EnableScriptGlobalization="false" EnableScriptLocalization="true"/>-->
<!--MS:<SharePoint:AjaxDelta id="DeltaSPWebPartManager" runat="server">-->
<!--MS:<WebPartPages:SPWebPartManager runat="server">-->
<!--ME:</WebPartPages:SPWebPartManager>-->
<!--ME:</SharePoint:AjaxDelta>-->

How you can change the name of SharePoint from Top Blue Bar

You can use powershell command to change or replace the name of SharePoint which is by default appear on top blue bar.

You can replace a "SharePoint" literal with these are the following options:
  • With Label
  • With Link
  • With Image & Link

===================================
With Label
===================================

Add-PSSnapin Microsoft.SharePoint.PowerShell

# get your site
$myApp = Get-SPWebApplication "http://mysite"

# add text
$myApp.SuiteBarBrandingElementHtml = '<div class="ms-core-brandingText">My Portal</div>'

# update
$myApp.Update()


===================================
With Link
===================================

Add-PSSnapin Microsoft.SharePoint.PowerShell

# get your site
$myApp = Get-SPWebApplication "http://mysite"

# add a linked text
$myApp.SuiteBarBrandingElementHtml = '<div class="ms-core-brandingText"><a style="color:#fff;" href="http://myportal">My Portal</a></div>'

# update
$myApp.Update()


===================================
With Image & Link
===================================

Add-PSSnapin Microsoft.SharePoint.PowerShell

# get your site
$myApp = Get-SPWebApplication "http://mysite"

# add an logo image
# $myApp.SuiteBarBrandingElementHtml = '<div class="ms-core-brandingText"><a href="http://myportal"><img src="/SiteCollectionImages/Logo.png"/></a></div>'

# update
$myApp.Update()