How to enable PowerShell remoting to execute tasks remotely in SharePoint

Here’s a quick and short summary on enabling PowerShell Remoting(PSRemoting) so you can perform SharePoint administration by using powershell to run SharePoint commands on a SharePoint server from your local laptop or workstation.

Consider an environment with SharePoint server XYZ.contoso.com

Server-side Steps:

On server XYZ.contoso.com, open Windows powershell and run the following commands:

 $computer = “XYZ”

winrm quickconfig 

Enable-WSManCredSSP -Role Server 

Connect-WSMan -ComputerName $computer

Set-Item “WSMAN:\$computer\service\auth\credssp” -Value $true

 

Client-side Steps:

Enable Windows Remoting and CredSSP

On the local workstation or laptop from where you want to connect to the server XYZ, open Windows powershell and run the following commands:

winrm quickconfig

Enable-WSManCredSSP -Role client -DelegateComputer XYZ.contoso.com –Force

 

Enabling in registry

Open registry by going to Run ->  regedit. Add the following entry to registry:

Set-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Control\Lsa\Credssp\PolicyDefaults\AllowFreshCredentialsDomain -Name WSMan -Value “WSMAN/*.contoso.com”

Allowing Credential delegation via Group Policy

Now make following changes to Group Policy:

Go to Run -> gpedit.msc

Navigate to

Computer Configuration > Administrative Templates > System > Credentials Delegation

Double-click

Allow Delegating Fresh Credentials

Select               Enabled

Click                  Add servers to the list: Show

Add WSMAN/*contoso.com

Click                  OK

Click                  OK

Go to Run -> gpedit.msc

Navigate to

Computer Configuration > Administrative Templates > System > Credentials Delegation

Double-click

Allow Delegating Fresh Credentials with NTLM-only Server Authentication

Select               Enabled

Click                  Add servers to the list: Show

Add WSMAN/*contoso.com

Click                  OK

Click                  OK

GP

GP2

PS Remoting

Now we can test the powershell remote connection. On your local workstation where you enabled PS Remoting using the client side steps above, type:

Enter-PsSession -computer U1VMPRTNRPCS01.production.online.dell.com -Auth Credssp -Credential “domain\serviceaccount”

PSSession

You would see a popup window again prompting you for credentials. Once you enter, it should now change shell to XYZ.contoso.com. Enable SharePoint Snapin using:

 

[XYZ.contoso.com]: PS C:\WINDOWS\system32> Add-pssnapin microsoft.sharepoint.powershell

 

To test whether you can execute SharePoint commands, try any command like:

[XYZ.contoso.com]: PS C:\Users\<serviceaccount>\Documents> Get-SPSolution

PSSnapin

Now you can execute SharePoint commands using powershell. Once done just close the powershell window or type “exit” to return back to the shell of your machine.

Note: As a security practice disable Win remoting and Cred SSP on Production machines after use using following commands:

Disable-WSManCredSSP -Role Server

Set-Item “WSMAN:\$computer\service\auth\credssp” -Value $false

Happy PSRemoting!! 🙂

Advertisements

SharePoint 2013 SP1 installation failing with event id: 1000, “Faulting application name: MsiExec.exe”

I was trying to build a new box with SharePoint 2013 SP1 slipstreamed. The install kept failing with the error:

Log Name: Application
Source: Application Error
Event ID: 1000
Task Category: (100)
Level: Error
Keywords: Classic
User: N/A
Computer: *****
Description:
Faulting application name: MsiExec.exe, version: 5.0.9600.16384, time stamp: 0x5215f49e
Faulting module name: KERNELBASE.dll, version: 6.3.9600.16408, time stamp: 0x523d557d
Exception code: 0xe06d7363
Fault offset: 0x000000000000ab78
Faulting process id: 0x1718
Faulting application start time: 0x01cf58bdd3e6f830
Faulting application path: C:\Windows\System32\MsiExec.exe
Faulting module path: C:\Windows\system32\KERNELBASE.dll
Report Id: 7b39da05-c4b1-11e3-80c1-1803732dc367

 

None of the steps like re-registering msiexec, clearing temp folder, rebooting computer etc. helped.

Finally, my friend Nishant Shah, a SharePoint Support Escalation Engineer in Microsoft asked me to check the following registry entries and delete them if  present: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\FileRenameOperations

I found there was an entry for FileRenameOperations and deleted that registry key.

Lo, this time the SharePoint install went on flawlessly. (Thanks Nishant!! 🙂 )

Hope this bit helps you if you encounter a similar issue.

SharePoint 2013 – Couldnt find location with internal name LocalSearchIndex

 

While doing a search from the site using the Core Results web part, no results were being returned.

On checking ULS logs, we saw errors like:

03/12/2014 22:55:33.01 w3wp.exe (0x446C) 0x666C SharePoint Server Search Query dn0c High CoreResultsDatasourceView: Couldnt find location with internal name LocalSearchIndex 17bc7c9c-9bea-e070-a5b0-675cbbde48b9

03/12/2014 22:55:33.02 w3wp.exe (0x446C) 0x666C SharePoint Server Search Query dn0a High CoreResultsWebpart: Couldnt find location with internal name LocalSearchIndex 17bc7c9c-9bea-e070-a5b0-675cbbde48b9

 

When we issue a query, we are directed to either the OSSSearchResults.aspx or /Search/Page/results.aspx, the results web part and the web parts in that page will use the LocationConfigurations where this consuming farm failed to have it. It seems that consuming farm is not loading correctly the location configuration from federated location in publishing farm.

Solution

Generally the way we fix the missing MSSLocations entries in the DB is to run the following PowerShell

## Set the Search Service Application Variable ##

##Put the name of Search Service Application you created in “ ”##

$ssa = Get-SPEnterpriseSearchServiceApplication “Search Service Application”

 

## Set the SSA Object to a Disabled State. Moving it from Online to Disabled”

$ssa.Status = “Disabled”

## Update the actual object and the persisted object on the servers ##

$ssa.Update()

## Call the Provision method to invoke a method that should create the OOB location configurations again in the SSA Admin DB ##

$ssa.Provision()

This updated the missing MSSLocations entries in the DB and search results came up properly now.

Thanks to Microsoft PFE Sushant Rane who dug this solution up!!!

SharePoint 2013 – Left Navigation and top Navigation bar does not render links and shows error: “An error occurred while rendering navigation for requested URL”

 

On the SharePoint site, we were seeing error in navigation in the quick launch. If we try to go to the navigation link in the site collection that failed as well. The error that showed up was:

An error occurred while rendering  navigation for requested  URL: /sites/<toplevelsite>/<variation>. Exception message: Object reference not set to an instance of an object. Stack trace: at Microsoft.SharePoint.publishing.publishingpage.geteffectivepagecacheprofileid

 

image

 

In ULS logs, we could see messages like:

Application error when access /_layouts/15/AreaNavigationSettings.aspx, Error=Object reference not set to an instance of an object. 

at Microsoft.SharePoint.Publishing.PublishingPage.GetEffectivePageCacheProfileId(Boolean anonUserProfile)   

at Microsoft.SharePoint.Publishing.CachedPage..ctor(PublishingPage page, SPListItem altItem, String id, String parentId, CachedUserResource title, String url, CachedUserResource description, CachedObjectFactory factory, List`1& fieldInfo)   

at Microsoft.SharePoint.Publishing.CachedPage.CreateCachedPage(PublishingPage page, SPListItem altItem, CachedObjectFactory factory, List`1& fieldInfo)   

at Microsoft.SharePoint.Publishing.CachedListItem.CreateCachedListItem(SPListItem item, SPListItem alternateItem, Boolean parentIsWeb, CachedObjectFactory factory, List`1& fieldInfo)   

at Microsoft.SharePoint.Publishing.CachedObjectFactory.CreateWrappedObject(SPListItem superUserVersion, SPListItem superReaderVersion, List`1& fieldInfo)   

at Microsoft.SharePoint.Publishing.CachedArea.GetChildForListByQuery(String listName, SPQuery query, SPWeb contextWeb, Boolean onlyPopulateCache, Boolean skipIfThrottled, List`1& itemsFetched)   

at Microsoft.SharePoint.Publishing.Navigation.PortalWebSiteMapNode.FetchDynamicItems(PublishingWeb pubWeb, NodeTypes includedTypes, Boolean& websFetched, Boolean& pagesFetched)   

at Microsoft.SharePoint.Publishing.Navigation.PortalWebSiteMapNode.PopulateNavigationChildrenInner(NodeTypes includedTypes)   

at Microsoft.SharePoint.Publishing.Navigation.PortalWebSiteMapNode.PopulateNavigationChildren(NodeTypes includedTypes)   

at Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapNode.GetNavigationChildren(NodeTypes includedTypes, NodeTypes includedHiddenTypes, Boolean trimmingEnabled, OrderingMethod ordering, AutomaticSortingMethod method, Boolean ascending, Int32 lcid)   

at Microsoft.SharePoint.Publishing.Internal.CodeBehind.AreaNavigationSettingsPage.AddChildrenToControl(String parentId, PortalSiteMapNode node, Int32 depth, Int32 maxDepth)   

at Microsoft.SharePoint.Publishing.Internal.CodeBehind.AreaNavigationSettingsPage.InitializeNavigationEditSort()   

at Microsoft.SharePoint.Publishing.Internal.CodeBehind.AreaNavigationSettingsPage.OnLoad(EventArgs e)   

at System.Web.UI.Control.LoadRecursive()   

at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

————————————————————————–

System.NullReferenceException: Object reference not set to an instance of an object.  

at Microsoft.SharePoint.Publishing.PublishingPage.GetEffectivePageCacheProfileId(Boolean anonUserProfile)   

at Microsoft.SharePoint.Publishing.CachedPage..ctor(PublishingPage page, SPListItem altItem, String id, String parentId, CachedUserResource title, String url, CachedUserResource description, CachedObjectFactory factory, List`1& fieldInfo)   

at Microsoft.SharePoint.Publishing.CachedPage.CreateCachedPage(PublishingPage page, SPListItem altItem, CachedObjectFactory factory, List`1& fieldInfo)   

at Microsoft.SharePoint.Publishing.CachedListItem.CreateCachedListItem(SPListItem item, SPListItem alternateItem, Boolean parentIsWeb, CachedObjectFactory factory, List`1& fieldInfo)   

at Microsoft.SharePoint.Publishing.CachedObjectFactory.CreateWrappedObject(SPListItem superUserVersion, SPListItem superReaderVersion, List`1& fieldInfo)   

at Microsoft.SharePoint.Publishing.CachedArea.GetChildForListByQuery(String listName, SPQuery query, SPWeb contextWeb, Boolean onlyPopulateCache, Boolean skipIfThrottled, List`1& itemsFetched)   

at Microsoft.SharePoint.Publishing.Navigation.PortalWebSiteMapNode.FetchDynamicItems(PublishingWeb pubWeb, NodeTypes includedTypes, Boolean& websFetched, Boolean& pagesFetched)   

at Microsoft.SharePoint.Publishing.Navigation.PortalWebSiteMapNode.PopulateNavigationChildrenInner(NodeTypes includedTypes)   

at Microsoft.SharePoint.Publishing.Navigation.PortalWebSiteMapNode.PopulateNavigationChildren(NodeTypes includedTypes)   

at Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapNode.GetNavigationChildren(NodeTypes includedTypes, NodeTypes includedHiddenTypes, Boolean trimmingEnabled, OrderingMethod ordering, AutomaticSortingMethod method, Boolean ascending, Int32 lcid)   

at Microsoft.SharePoint.Publishing.Internal.CodeBehind.AreaNavigationSettingsPage.AddChildrenToControl(String parentId, PortalSiteMapNode node, Int32 depth, Int32 maxDepth)   

at Microsoft.SharePoint.Publishing.Internal.CodeBehind.AreaNavigationSettingsPage.InitializeNavigationEditSort()   

at Microsoft.SharePoint.Publishing.Internal.CodeBehind.AreaNavigationSettingsPage.OnLoad(EventArgs e)   

at System.Web.UI.Control.LoadRecursive()   

at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

 

After a lot of troubleshooting (we engaged Microsoft) this was final the resolution to fix the issue:

 

———————————

Resolution:

———————————

§  First, disabled and re-enabled Publishing feature and Navigation feature for all sites using the powershell script  which would loop through all subsites:

Get-SPWeb -site http://server/sites/channel -limit ALL | ForEach-Object {Disable-SPFeature Publishing -Url $_.Url -confirm:$false}

Get-SPWeb -site http://server/sites/channel -limit ALL | ForEach-Object {Disable-SPFeature PublishingWeb -Url $_.Url -confirm: $false}

IISreset

Get-SPWeb -site http://server/sites/channel -limit ALL | ForEach-Object {Enable-SPFeature Publishing -Url $_.Url -confirm:$false}

Get-SPWeb -site http://server/sites/channel -limit ALL | ForEach-Object {Enable-SPFeature PublishingWeb -Url $_.Url -confirm: $false}

 

§ Unchecked following options in the site collection output cache settings:

                Publishing sites can use a different page output cache profile

                Page layouts can use a different page output cache profile

 

image

 

After we disabled, Site OutPut cache, the error disappeared. The reason seems to be that I had not set separate Portal Super User and Portal Super Reader accounts. Instead, SharePoint was trying to application pool account was or service account  to display cached information for every user who opened the page. This was resulting in Navigation to be corrupted.

If you would like to use Output Cache for performance is your site it is recommended to setup object cache user accounts (Portal Super User and Portal Super Reader accounts). Please refer following article for details:

http://technet.microsoft.com/en-us/library/ff758656.aspx

(I tried this at my box, but even after enabling Portal Super User and Portal Super Reader accounts as per above, it did not fix the issue for me. I had to keep the Site Output Cache disabled to Navigation to work )

SharePoint 2013 – Content Deployment fails with error “Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx) at Microsoft.SharePoint.Library.SPRequest.ImportNavigationXml”

After migrating a SharePoint 2007 environment to SharePoint 2013, I encountered countless nightmares during content deployment. I plan to consolidate the whole story in a separate blog.

But thought it would be useful to blog this immediately for those out there still using Content deployment in SharePoint 2013.

Import was failing and the error in ImportExport log was:

[*/*/2014 4:16:21 AM] Verbose: Performing final fixups.

[*/*/2014 4:16:53 AM] FatalError: Cannot complete this action.

Please try again.

[*/*/2014 4:16:53 AM] Debug:    at Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx)

at Microsoft.SharePoint.Library.SPRequest.ImportNavigationXml(String bstrUrlWeb, String bstrNavXml, Boolean fClearNavigation)

at Microsoft.SharePoint.Deployment.ImportObjectManager.ImportWebStructure()

at Microsoft.SharePoint.Deployment.SPImport.DeserializeObjects()

at Microsoft.SharePoint.Deployment.SPImport.Run()

[*/*/2014 4:17:21 AM] Progress: Import did not complete.

We finally had to open a case with Microsoft and they confirmed it was a bug fixed by http://support.microsoft.com/kb/2837677  and the specific issue is (as one of the issues listed in that KB)

When you use PRIME to import a site in SharePoint Server 2013, the import fails if global navigation is not inherited.

Describe the problem

Import-SPWeb and Content Deployment does not work in SharePoint 2013 if the site structure contains at least one subsite which does not inherit global navigation.

Here are steps took in order to reproduce the navigation error using PRIME

  1. Created a new Site Collection in a Web Application based on Publishing
  2. Created a new Sub-Site under this Site Collection.  I chose the option “no” for “Use the top link bar from the parent site”
  3. After creating, exported the top level Site using export-spweb
  4. Then created a new Site Collection with the option to “choose a template later”
  5. Imported the top level Site that was exported in step 3 to the new Site Collection using import-spweb
  6. This failed with the error:

So, the final solution provided by Microsoft was

  1. Install the hotfix http://support.microsoft.com/kb/2837677
  2. or Install the December 2013 CU http://support.microsoft.com/default.aspx?scid=kb;EN-US;2850024
  3. or better yet, install SharePoint 2013 SP1  http://support.microsoft.com/kb/2850035

We went with option 1,  hotfix http://support.microsoft.com/kb/2837677 and I am happy to say that content deployment completed successfully.

Yet another lesson that SharePoint achieves reasonable stability only with Service Pack.

SharePoint 2013–While updating a list or adding a new user, getting error “The server was unable to save the form at this time. Please try again”

Recently users and I started getting error when trying to update a list or adding a new user:

The server was unable to save the form at this time. Please try againimage

server error

As a Farm administrator and site collection administrator, I had full access to the site. Also, earlier I had no issues updating lists, so it was flabbergasting at first why this error was cropping up.

Then I remembered that the only change I made to environment was to add multiple bindings in the site.

e.g.

I had added both server:8080 and server.production.online.domain.com:8080 to IIS bindings.

Further, a quick search on the net gave me multiple articles about WCF having issues with multiple bindings (http://mrhodes.net/2010/03/30/sharepoint-designer-2010-the-server-could-not-complete-your-request-the-content-type-of-the-response-is-8/, http://social.msdn.microsoft.com/Forums/vstudio/en-US/96390c8b-efa1-4471-8f36-6cd615c5f120/iis-hosted-wcf-with-two-bindings?forum=wcf etc.)

So, as soon as I removed the additional binding e.g. server:8080, I was able to edit lists without the above error!

SharePoint 2013 – Fix all issues reported in “Content Deployment Source Status”

 

Content deployment steps have changed a bit with SharePoint 2013.  It has introduced an option to do a “Source Status check” in which can be found in Central Administration under –> General Application Settings –> Configure content deployment.

image

 

 

If this is enabled at Destination site, you cannot create a Content Deployment Path\Job until you fix all the issues.

 

image

 

As such when you proceed to create a content deployment path, it might fail and ask you to fix issues at source.

To find issues at source,  on a Source Site Collection e.g. I have used a site collection http://<>:8080/sites/channel. Go to Site Settings -> Content Deployment Source Status and verify there are no errors.

image

 

In case you cant find it, you need to enable the feature from Site collection Features

 

image

 

image

 

 

After you enable Content Deployment Source Status and go there, if errors are seen, e.g. missing features, remove them using PowerShell or a tool like SharePoint Feature Admin Tool.

image

 

After you do remediation the page should show no errors as below

image

Remediation with SharePoint Feature Admin Tool

Disclaimer: SharePoint Feature Admin is a free third party tool available from Microsoft CodePlex site. While I have had no issues at all with it and would highly recommend this tool for its ease of use, please use it at your own risk. Be sure to test it on Test\Development environment before testing on Production.

 

Launch the FeatureAdmin2013.exe with Admin\Service Account.

i. Under Web applications, select Channel – 8080,

ii. Under Site Collections within this Web Applications select http://<server or FQDN>/sites/channel

iii. Click Find Faulty Feature in Farm

image

iv. For each Faulty feature found, it will show a popup and give option to remove it. Click Ok until all faulty features are removed.

image

v. Now select http://<server or FQDN>/sites/channel in Web site within selected Site Collection, select Remove/Deactivate features in selected sites, check all features showing error and click first on Remove Feature from Farm and it says it’s a site collection feature then click on Remove from selected Site Collection.

image

vi. Click Ok on the popup

image

vii. Click on Reload Web apps and then repeat steps i, ii, and v. Cycle through each subsite and remove any error feature by first clicking on Remove Feature from Farm and it says it’s a site feature clicking on Remove from selected Site(SPweb) until all faulty(or unwanted or missing) features are removed.

Remove faulty/missing/unwanted features listed in Content Deployment Source Status page using same steps listed above.

image

e.g. Ratings is listed as an unsupported feature at Home which is http://<server>/sites/channel

image

In FeatureAdmin Tool, select site collection and locate the Ratings feature under Remove/deactivate features in selected sites and then click on Remove feature from farm.

image

Click Yes on the popup.

image

Similarly locate and remove all missing\unsupported\unwanted features from both Site Collection Features (SPSite) and Site Features (SPWeb) until the Content Deployment Source Status page shows no more errors .

Once all errors are removed, SharePoint will allow you to create a content deployment path and job for that site collection.