SharePoint 2013: How to verify ULS log and Usage log file access

Title

How to verify ULS log and Usage log file access in SharePoint 2013 via PowerShell

Business Goal

Recently I had an incident involving Usage reports that weren’t working properly in a SharePoint 2013 farm. I found a nice troubleshooting article which really helped: Snowburnt…IT happens – How to troubleshoot SharePoint Usage Reports Usage Reports.

One of the checks was what the group permissions of the WSS_WPG and WSS_ADMIN_WPG were on the ULS and Usage log file directory on the different servers in the SharePoint 2013 farm. Since I didn’t wanted to uses explorer I decided to create a script to analyse this.

Technical Overview

The solution is a PowerShell script that uses some different cmdlets (Get-SPServer & Get-SPUsageService) from the SharePoint module and the Get-Acl cmdlet. From the Usage Service you can easily get the usage and log file directory path. Via an UNC path you can check the group permissions via the Get-Acl cmdlet. I use the Get-SPServer to determine on which servers to check these permissions.

Prerequisites

To complete this how-to, you must have the following prerequisites must be met:
– A domain account that can log on to one of the SharePoint 2013 servers
– A domain account that has privileges to manage SharePoint 2013 via PowerShell (SPShellAdmin role)

Steps

1. Run the Powershell script .\verify_logfileaccess.ps1

Additional resources

Gallery Technet – Verify ULS and Log file access
Snowburnt…IT happens – How to troubleshoot SharePoint Usage Reports Usage Reports
Technet Library – Account permissions and security settings in SharePoint 2013
Technet Library – Get-Acl
Technet Library – Get-SPServer
Technet Library – Get-SPUsageService

Applies to

SharePoint 2013

Change History

22-09-2016 – 1.0

SharePoint 2013: Not able to connect to search service to retrieve valid settings

KBID

EXP-INC-00001

Title

Not able to connect to search service to retrieve valid settings

Introduction

In SharePoint 2013 there are some changes in how search work. Result sources replace scopes and federated locations. Other changes in search can be found overhere on Technet.

In a result source you can restrict queries to a subset of content by using a query transform. You can use the query builder interface for building such a results source. In SharePoint 2013, site collection administrators, site owners, and site designers can also create and configure result sources to meet their specific requirements.

This article describes how I ran into an issue with building a new results source in the query builder in Central Administration.

Symptoms

When you try to create a new result source from Central Administration in your Search Service Application you get an error:
Error: Not able to connect to search service to retrieve valid settings

Error: Not able to connect to search service to retrieve valid settings

Steps to Reproduce

1. Navigate to Central Administration
2. Go to Application Management > Manage service applications and select your Search Service Application
3. Go to Queries and Results > Results Sources
4. Click on the New Result Source button

Cause

Basicly the cause of this error is that the account which you use to access the Query Builder is not authorized to do this.

To see the cause you can open the ULS logs of SharePoint 2013, with a tool like ULS Viewer. When you find the right correlation you get an event of the level Unexpected:
Exception in Query Builder OnLoad: System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: Attempted to perform an unauthorized operation. (Fault Detail is equal to An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is: System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.
at Microsoft.Office.Server.Search.Administration.Ranking.GetRankingModels()
at SyncInvokeGetRankingModels(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)).

SharePoint log error

Btw, if you having trouble filter your log on the following fields and corresponding values, Product – SharePoint Server Search & Category – Query.

Applies to

SharePoint 2013

Workaround

Not Applicable

Solution

Add the account with Full Control permissions to the Administrators for Search Service Application. You can do this via the interface in Central Administration or via Powershell. On TechNet this described in detail, Assign or remove administrators to a service application (SharePoint 2013).

References

Majorbacon – Error: "Not able to connect to search service to retrieve valid settings" or Why won’t my query builder work?
Technet – Assign or remove administrators to a service application (SharePoint 2013)
Technet – Understanding result sources for search in SharePoint Server 2013
Technet – What’s new in search in SharePoint Server 2013