Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 7025

Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 2162

Deprecated: Hook imagify_allow_picture_tags_for_webp is deprecated since version 2.2! Use imagify_allow_picture_tags_for_nextgen instead. in /www/collab365_296/public/wp-includes/functions.php on line 5758
Change Service Identities for SPTraceV4 and AppFabricCachingService - Collab365
Deprecated: strstr(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1145

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1152

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1155

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1162

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1165

Deprecated: strstr(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1145

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1152

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1155

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1162

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1165

Warning: Undefined array key "url" in /www/collab365_296/public/wp-content/plugins/thrive-visual-editor/thrive-dashboard/inc/smart-site/classes/class-tvd-smart-shortcodes.php on line 85

2013-06-12

After installing SharePoint, you start noticing some health warnings in Central Administration which tell you that you shouldn’t use built-in accounts for application pools or service identities.

For SharePoint 2013, 2 of the services which you will find running typically under a built-in account are:

  • SharePoint Tracing Service (SPTraceV4)
  • Distributed Cache Service (AppFabricCachingService)

It’s actually pretty easy to change the identities of those services and switch them to a domain account.

Just use the following 2 scripts to make it happen.

SPTraceV4

<#
.SYNOPSIS
   Specify a new service identity for the SPTraceV4 Windows Service.

.DESCRIPTION
   Specify a new service identity for the SPTraceV4 Windows Service.

.NOTES
   File Name: Set-ServiceIdentityForSPTraceV4Service.ps1
   Version  : 1.0

.PARAMETER AccountName
   Specifies the name of the account which will be used (domain\name).

.EXAMPLE
   PS > .\Set-ServiceIdentityForSPTraceV4Service.ps1 -AccountName "westeros\sp_service"

#>
[CmdletBinding()]
param(
   [parameter(Position=0,Mandatory=$true,ValueFromPipeline=$false)]
   [string]$AccountName
)

# Load the SharePoint PowerShell snapin if needed 
if ((Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -EA SilentlyContinue) -eq $null)
{
   Write-Host "Loading the SharePoint PowerShell snapin..."
   Add-PSSnapin Microsoft.SharePoint.PowerShell
} 

# Get the tracing service.
$svc = (Get-SPFarm).Services | ? {$_.Name -eq "SPTraceV4"}

# Get the managed account from SharePoint
$svcIdentity = Get-SPManagedAccount $AccountName

# Set the tracing service to run under the managed account. $svc.ProcessIdentity.CurrentIdentityType = "SpecificUser"
$svc.ProcessIdentity.ManagedAccount = $svcIdentity
$svc.ProcessIdentity.Update()

# This actually changes the "Run As" account of the Windows service.
$svc.ProcessIdentity.Deploy()

# Add the domain account to the local "Performance Log Users" group
$Domain,$User = $AccountName.Split("\")
Try
{
   [ADSI]"WinNT://$env:COMPUTERNAME/Performance Log Users,group").Add("WinNT://$Domain/$User")
}
catch
{
   Write-Host "$UserName is already a member of the Performance Log Users group."
}

After you run this script, make sure that you repeat the last part of the script (the part where you add the account to the Performance Log Users) on the other servers of your farm as well. Otherwise, you will see your ULS logfiles getting created on those servers but they are not filled.

AppFabricCachingService

You need to run this script on the server which is used for the Distributed Cache Service.

<#
.SYNOPSIS
   Specify a new service identity for the Distributed Cache Service.

.DESCRIPTION
   Specify a new service identity for the Distributed Cache Service.

.NOTES
   File Name: Set-ServiceIdentityForDistributedCacheService.ps1
   Version  : 1.0

.PARAMETER AccountName
   Specifies the name of the account which will be used (domain\name).

.EXAMPLE
   PS > .\Set-ServiceIdentityForDistributedCacheService.ps1 -AccountName "westeros\sp_service"

#>
[CmdletBinding()]
param(
   [parameter(Position=0,Mandatory=$true,ValueFromPipeline=$false)]
   [string]$AccountName
)

# Load the SharePoint PowerShell snapin if needed 
if ((Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -EA SilentlyContinue) -eq $null)
{
   Write-Host "Loading the SharePoint PowerShell snapin..."
   Add-PSSnapin Microsoft.SharePoint.PowerShell
} 

# Get the tracing service.
$svc = (Get-SPFarm).Services | ? {$_.Name -eq "AppFabricCachingService"}

# Get the managed account from SharePoint
$svcIdentity = Get-SPManagedAccount $AccountName

# Set the tracing service to run under the managed account. $svc.ProcessIdentity.CurrentIdentityType = "SpecificUser"
$svc.ProcessIdentity.ManagedAccount = $svcIdentity
$svc.ProcessIdentity.Update()

# This actually changes the "Run As" account of the Windows service.
$svc.ProcessIdentity.Deploy()

Should do the trick.

 

(Visited 510 times, 1 visits today)

About the author 

Bart Kuppens

Summit Bundle

Get 200+ hours of Microsoft 365 Training for 27$!

Master Office 365, Power Platform & SharePoint & Teams With 200+ Hours Of Training Videos and 108 Ebooks in the Collab365 Academy. This offer is insane and is only available for a limited period.