Thursday 22 December 2016

Adding Sandbox Solution in Solution gallery using power shell

In this post I am going to share below code the add and install the partial trust solution in solution gallery using Powershell script.


$WebApp= Get-SPWebApplication http://sharepointtest:5555
$site = Get-SPSite -WebApplication $WebApp -Limit All
$Sites = Get-SPSite -Limit All
foreach($Site in $Sites)
{

Add-SPUserSolution –LiteralPath "{WSP Path}" –Site $Site.Url

Install-SPUserSolution –Identity "{WSP Name}" –Site $Site.Url

}

Tuesday 20 December 2016

"Upgrade Required" Status in SharePoint 2013 Central Administration Servers in Farm



Problem -
 

"Upgrade Required" error message in SharePoint 2013 server farm?

Background –


After the service pack installation was completed I notice that “Upgrade Require” message was

appearing in Central admin server farm as shown in below screenshot.



I run the configuration wizard right after the installation of Service Pack but the farm status 

continues to show “upgrade required” 

Resolution -


   1. Find out the error in the upgrade log.
   2. To know what objects needed upgrade in the farm. I ran stsadm.exe -o      localupgradestatus after running this I got the list of object and summary out of them filter the “need to upgraded” record.

 <object>
    <name>Microsoft.SharePoint. Administration.SPIisWebSite</name>
    <type>Microsoft.SharePoint. Administration.SPIisWebSite</type>
    <level>5</level>
    <status>Needs Upgrade</status>
 </object>

[25] content database(s) encountered.
[0] content database(s) still need upgrade or cannot be upgraded.
[30] site collection(s) are contained in the content databases.
[0] site collection(s) still need upgrade.
[40] other objects encountered,
[1] of them still need upgrade or cannot be upgr
aded.




     I tried to ran the PSConfig.exe   


3. I tried to ran the PSConfig.exe -cmd upgrade -inplace b2b -force -cmd applicationcontent -install -cmd installfeatures But it was getting failed every time with the following error message



An exception of type Microsoft.SharePoint.Upgrade.SPUpgradeException was thrown.

Additional exception information: Action 15.0.1.0 of Microsoft.SharePoint.Upgr
     ade.SPIisWebSiteWssSequence failed. 

    4. I also ran the below script that loops through the web applications and pings each one confirming that web application is exists or not 




          $webapps = Get-SPWebApplication
           foreach($web in $webapps)
            {
             ping $web.url.replace(“http:”,””).replace(“https”,””).replace(“/”,””) -n 1

            }
 

    5. I found that few of the web applications removed from SharePoint Central admin but it was still appearing in IIS.



I tried to delete the blank web application from SharePoint Central admin UI as show in      below screenshot 



but I was not able to delete it from UI and received the below error.


An object of the type Microsoft.SharePoint. Administration.SPIisWebsiteUnprovisioningJobDefinition named "Unprovisioning SharePoint - 47017" already exists under the parent Microsoft.SharePoint.Administration.SPWebService named "". Rename your object or delete the existing object
        
I used below PowerShell script to delete the orphan Web Application object



      Get-SPTimerJob | where {$_.name -like "*SharePoint - 444*”} |ft id,name

      copy the Timer Job Id

      $job = Get-SPTimerJob -Identity <paste the id here>

      $job.Delete()



After that I deleted the web application successfully using below PS command


 Remove-SPWebApplication http://sharepoint40/ -Confirm  -DeleteIISSite    -RemoveContentDatabases





       After removing all the unused/orphan web application site and application pool from IIS.
   I ran the below PS Script again

PSConfig.exe -cmd upgrade -inplace b2b -force -cmd applicationcontent -install -cmd installfeatures



And finally, “Upgrade Require” message disappeared !