Category: SharePoint 2016
Resetting Office 365 Cloud Search Index
From time to time we need to remove all the items out of the Office 365 search index. There are 3 options:
1. Re-index everything on premises and after the indexing completes delete the content sources to trigger a delete crawl to run. Of course re-indexing everything is not efficient, it takes time and if items have been deleted from the on premises content you still run the risk of missing orphans in the Office 365 search index.
2. Call Microsoft Office 365 support and raise a ticket to ask for an index purge, something that takes time and again is inefficient for the task at hand.
3. Use DeleteAllCloudHybridSearchContent method of PushTenantManager.
More information on DeleteAllCloudHybridSearchContent method can be found here and here.
That was another page in the Chronicles of SharePoint Bits, happy scripting!
Error: PowerShell ISE stopped working
PowerShell Integrated Scripting Environment is a very powerful and useful tool to create and debug PowerShell scripts. After installing some security patching and IRM component it stopped working and would crash:
The issue is related to the corrupt GlobalUserInterface.CompositeFont file. This causes PowerShell ISE. It also effects other WPF applications to fail as well. See this article: https://github.com/dotnet/announcements/issues/53.
We used the Solution 3:
## ## xcopy /y GlobalUserInterface.CompositeFont %windir%\Microsoft.NET\Framework\v4.0.30319\WPF\Fonts xcopy /y GlobalUserInterface.CompositeFont %windir%\Microsoft.NET\Framework64\v4.0.30319\WPF\Fonts ## ##
That was another page in the Chronicles of SharePoint Bits, happy scripting!
Howto: Check all the sites in the particular Content DB
From time to time, there is a need to check the SharePoint sites is a particular content database are accessible. There is a simple script for it: enumerate all the sites in the DB and Invoke a Web Request for the site URL. The returned Web request code will indicate if site is accessible or not:
#################################################################################################### # # Author.......: David Shvartsman # Date.........: 07/05/2018 # Description..: Check all the sites in the particular Content DB # #################################################################################################### #Load SharePoint PowerShell Snapin if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) { Add-PSSnapin "Microsoft.SharePoint.PowerShell" } $db = "Content_DBName" $Sites = Get-SPSite -ContentDatabase $db -Limit All foreach ($site in $sites) { $SiteStatus = Invoke-WebRequest -Uri $site.url -UseDefaultCredentials | Select-Object StatusCode If ($siteStatus.StatusCode -eq 200) { Write-host "$($site.url) is OK." -ForegroundColor Green } Else { Write-Host "Failed check for $($site.url)" -ForegroundColor Red } } ####################################################################################################
That was another page in the Chronicles of SharePoint Bits, happy scripting!
Troubleshooting: Collecting Verbose ULS logs
Working with Microsoft on the one of the issues we were asked to provide verbose ULS logs. Having the ULS logs in verbose mode might take a lot of disk space. Here is a simple solution: enable the verbose logging only for the period of time to reproduce the issue and switch it back to default level when done. PowerShell to the rescue: the following script will change the ULS log level to verbose and pause while you can reproduce the issues that is being troubleshooted. Just press the enter button after that and it will switch the log level to default (Information). If your default log level is different from Information modify the script accordingly. The script will generate Merged ULS log for the period between the start of the script and the time you pressed the Enter button to continue.
#################################################################################################### # # Author.......: David Shvartsman # Date.........: 06/27/2018 # Description..: Troubleshooting: Collecting Verbose ULS logs # #################################################################################################### if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) { Add-PSSnapin "Microsoft.SharePoint.PowerShell" } CLS $startDate = (Get-Date -format "MM/dd/yyyy HH:mm:ss") set-sploglevel -traceSeverity verbose pause $endDate = (Get-Date -format "MM/dd/yyyy HH:mm:ss") Clear-SPLogLevel $logfile = "d:\temp\ULSLogFileName.log" if (test-path $logfile) { Remove-Item $logfile } Merge-SPLogFile –Path $logfile –StartTime $startDate –EndTime $endDate ####################################################################################################
That was another page in the Chronicles of SharePoint Bits, happy scripting!
Audience Compilation Status is ‘Compiling’ for a long time
Looking at Central Administration console under Manage Profile Service we have noticed that Audience Compilation Status shows ‘Compiling’ for a long time. There is no errors in the event logs. Attempts to stop compilation or compile an individual audience did not produce any results.
There is AudienceJob.exe executable that you can use to manipulate audiences:
AudienceJob.exe <Application Id> [Crawl Type] [Audience Name]
Application Id: Guid corresponding to UserProfile application
Command: 1 = Start, 0 = Stop
Crawl Type: 1 = Full, 0 = Incremental (default = 1)
Audience Name: Specific audience to compile (default = all)
#################################################################################################### # # Author.......: David Shvartsman # Date.........: 05/18/2018 # Description..: Restart Audience Compilation # #################################################################################################### if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) { Add-PSSnapin "Microsoft.SharePoint.PowerShell" } $ServiceType = "User Profile Service Application" $spService = Get-SPServiceApplication | where {$_.TypeName -like $ServiceType } $id = $spService.id Audiencejob.exe $id 0 Audiencejob.exe $id 1
You can use AudienceJob.exe to compile a specific audience.
It works in SharePoint 2010, SharePoint 2013 and SharePoint 2016.
That was another page in the Chronicles of SharePoint Bits, happy scripting!
Stopping SharePoint Service Instance on the Server
SharePoint Central Administration Portal provides a way to start/stop Services Instance on a particular server. It is accessible under Application Management/Service Applications/Manage Services on Server option. It is all good in the small environment but controlling the Service Instances in the big environment becomes cumbersome. PowerShell to the rescue. Bellow is a code to stop SharePoint Service Instance on the particular server:
#################################################################################################### # # Author.......: David Shvartsman # Date.........: 11/24/2017 # Description..: Stopping SharePoint Service Instance on the Server # #################################################################################################### if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) { Add-PSSnapin "Microsoft.SharePoint.PowerShell" } $ServerName = "Server Name" $ServiceType = "Services Application Name" $spService = Get-SPServiceInstance | where {$_.TypeName -eq $ServiceType -and $_.Server.name -eq $ServerName } $i = 0 if ($spService.Status -eq "Online") { Write-Host "Stopping $($ServiceType) on $($ServerName) Server..." -NoNewline ##$spService.Unprovision() $spService = Stop-SPServiceInstance $spservice.Id -Confirm:$false DO { write-host -NoNewline "." sleep 30 $spService = Get-SPServiceInstance $spService.Id $i++ } While (($spservice.Status -ne "Disabled") -and ($i -lt 10)) if ($spservice.Status -eq "Disabled") { Write-Host " Success!" -ForegroundColor Green } else { Write-Host " Failed!" -ForegroundColor Red } }
Services Application Names:
Access Database Service 2010 |
Access Services |
App Management Service |
Business Data Connectivity Service |
Central Administration |
Claims to Windows Token Service |
Distributed Cache |
Document Conversions Launcher Service |
Document Conversions Load Balancer Service |
Excel Calculation Services |
Lotus Notes Connector |
Machine Translation Service |
Managed Metadata Web Service |
Microsoft SharePoint Foundation Incoming E-Mail |
Microsoft SharePoint Foundation Sandboxed Code Service |
Microsoft SharePoint Foundation Subscription Settings Service |
Microsoft SharePoint Foundation Web Application |
Microsoft SharePoint Foundation Workflow Timer Service |
PerformancePoint Service |
PowerPoint Conversion Service |
Request Management |
Search Host Controller Service |
Search Query and Site Settings Service |
Secure Store Service |
SharePoint Server Search |
SQL Server PowerPivot System Service |
SQL Server Reporting Services Service |
User Profile Service |
User Profile Synchronization Service |
Visio Graphics Service |
Word Automation Services |
Service Application Instance Status:
Online |
Unprovisioning |
Disabled |
Provisioning |
That was another page in the Chronicles of SharePoint Bits, happy scripting!
Event ID 3351: SQL database login for ” on instance ” failed.
In certain environments you will see ‘Event ID 3355: SQL database login for ” on instance ” failed.’ in the event logs.
The errors are related to MOM/SCOM Agent trying to access some information from the SharePoint Configuration database under ‘Local System’ account and gets access denied.
Resolution:
To resolve the issue we need to grant SPShellAdmin access to Local System account to Configuration DB for each server in the farm:
#################################################################################################### # # Author.......: David Shvartsman # Date.........: 11/01/2017 # Description..: Fixing Event ID 3355: SQL database login for '<Config DB Name>' on instance '<SQL Instance Name>' failed. # #################################################################################################### if ((Get-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null) { Add-PSSnapin Microsoft.SharePoint.PowerShell } Add-PSSnapin Microsoft.SharePoint.Powershell $domainName = ((gwmi Win32_ComputerSystem).Domain).Split(".")[0] $Servers = get-spserver | ? { (($_.Role -eq "Application") -or ($_.Role -eq "SingleServer")) } foreach($Server in $Servers) { $serverName = $Server.Name Get-SPDatabase | where {$_.name -match "config"} | Add-SPShellAdmin -username "$domainName\$serverName$" }
That was another page in the Chronicles of SharePoint Bits, happy scripting!
Script to get User Properties under Manage Profile Service
As part of our current project we needed to recreate User Profile Application (UPA). Here is the PowerShell script in case you need to find the current configuration of User Properties under Manage Profile Service.
#################################################################################################### # # Author.......: David Shvartsman # Date.........: 11/17/2016 # Description..: Get the UPA Properties from the User Profile Service Application # #################################################################################################### <# .SYNOPSIS Get the UPA Properties from the User Profile Service Application. .DESCRIPTION Get the UPA Properties from the User Profile Service Application. .NOTES File Name: Get-UPS-AllProperties.ps1 Modified : David Shvartsman Version : 1.1 .PARAMETER OutputFile Specifies the name of the file where the output is written to. .EXAMPLE PS C:\> .\Get-UPS-AllProperties.ps1 -url "http://WebAppUrl" -connectionName "ConnectionName" -OutputFile "D:\temp\UPS_Properties.xml" #> [CmdletBinding()] param( [parameter(Position=0,Mandatory=$true,ValueFromPipeline=$false)] [string]$url="http://WebAppUrl", [parameter(Position=1,Mandatory=$true,ValueFromPipeline=$false)] [string]$connectionName="ConnectionName", [parameter(Position=2,Mandatory=$true,ValueFromPipeline=$false)] [string]$OutputFile = "D:\temp\UPS_Properties.xml") # 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 } CLS #Define our configuration. This is the name you gave the import connection to AD #Setup our SharePoint objects $site=Get-SPSite $url; $serviceContext= Get-SPServiceContext($site); $upManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($serviceContext); $syncConnection=$upManager.ConnectionManager[$connectionName]; #This is a collection of mappings to AD that we will use later $pmc=$syncConnection.PropertyMapping; #This is a collection of all of the properties which we will iterate $properties=$upManager.GetProperties(); # Create a new XML writer settings object $settings=New-Object system.Xml.XmlWriterSettings; $settings.Indent=$true; $settings.OmitXmlDeclaration=$false; $settings.NewLineOnAttributes=$true; # Create a new string writer to capture the output $sw=new-object System.IO.StringWriter; # Create a new XmlWriter $writer= [system.xml.XmlWriter]::Create($sw, $settings); #Start the document and add the root node $writer.WriteStartDocument(); $writer.WriteStartElement("properties"); #Iterate through the properties foreach ($item in $properties) { #Create the property element $writer.WriteStartElement("property"); #Add in the fields as attributes $writer.WriteAttributeString("Name", $item.Name); $writer.WriteAttributeString("DisplayName",$item.DisplayName); $writer.WriteAttributeString("ManagedPropertyName",$item.ManagedPropertyName); $writer.WriteAttributeString("Type",$item.Type); $writer.WriteAttributeString("ChoiceList",$item.ChoiceList); $writer.WriteAttributeString("Description",$item.Description); $writer.WriteAttributeString("URI",$item.URI); $writer.WriteAttributeString("IsSystem",$item.IsSystem); $writer.WriteAttributeString("AllowPolicyOverride",$item.AllowPolicyOverride); $writer.WriteAttributeString("IsUserEditable",$item.IsUserEditable); $writer.WriteAttributeString("IsAdminEditable",$item.IsAdminEditable); $writer.WriteAttributeString("IsImported",$item.IsImported); $writer.WriteAttributeString("Length",$item.Length); $writer.WriteAttributeString("IsMultivalued",$item.IsMultivalued); $writer.WriteAttributeString("ChoiceType",$item.ChoiceType); $writer.WriteAttributeString("DefaultPrivacy",$item.DefaultPrivacy); $writer.WriteAttributeString("UserOverridePrivacy",$item.UserOverridePrivacy); $writer.WriteAttributeString("IsReplicable",$item.IsReplicable); $writer.WriteAttributeString("PrivacyPolicy",$item.PrivacyPolicy); $writer.WriteAttributeString("DisplayOrder",$item.DisplayOrder); $writer.WriteAttributeString("IsColleagueEventLog",$item.IsColleagueEventLog); $writer.WriteAttributeString("IsAlias",$item.IsAlias); $writer.WriteAttributeString("IsSearchable",$item.IsSearchable); $writer.WriteAttributeString("IsUpgrade",$item.IsUpgrade); $writer.WriteAttributeString("IsUpgradePrivate",$item.IsUpgradePrivate); $writer.WriteAttributeString("IsVisibleOnEditor",$item.IsVisibleOnEditor); $writer.WriteAttributeString("IsVisibleOnViewer",$item.IsVisibleOnViewer); $writer.WriteAttributeString("IsTaxonomic",$item.IsTaxonomic); $writer.WriteAttributeString("Separator",$item.Separator); $writer.WriteAttributeString("MaximumShown",$item.MaximumShown); $writer.WriteAttributeString("IsSection",$item.IsSection); $writer.WriteAttributeString("IsRequired",$item.IsRequired); $writer.WriteAttributeString("SubtypeName",$item.SubtypeName); #Look up any AD mappings in the PropertyManagerCollection and include them $writer.WriteAttributeString("IsImport",$pmc.Item($item.Name).IsImport); $writer.WriteAttributeString("IsExport",$pmc.Item($item.Name).IsExport); $writer.WriteAttributeString("DataSourcePropertyName",$pmc.Item($item.Name).DataSourcePropertyName); $writer.WriteAttributeString("OriginalDataSourcePropertyName",$pmc.Item($item.Name).OriginalDataSourcePropertyName); $writer.WriteAttributeString("AssociationName",$pmc.Item($item.Name).AssociationName); $writer.WriteAttributeString("Connection",$pmc.Item($item.Name).Connection.DisplayName); $writer.WriteEndElement(); } #Finish up $writer.WriteEndElement(); $writer.WriteEndDocument(); $writer.Flush(); $writer.Close(); #Capture the output into a string $result=$sw.ToString(); # Write the XML out #Write-Output $result; $result | out-file $OutputFile -force
The next step will be creating/updating User Properties under Manage Profile Service based on the XML file produced by this script.
That was another page in the Chronicles of SharePoint Bits, happy scripting!
Problem with 2013 Workflow Instance geting suspended with “There has been an error authenticating the request” massage
From time to time we are having an issues with SharePoint 2013 Workflows going to Suspended stage with the following error:
RequestorId: 647a2bdb-7a39-cb3c-0000-000000000000. Details: An unhandled exception occurred during the execution of the workflow instance. Exception details: System.ApplicationException: HTTP 401 {"error_description":"The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs."} {"x-ms-diagnostics":["3001000;reason=\"There has been an error authenticating the request.\";category=\"invalid_client\""],"SPRequestGuid":["647a2bdb-7a39-cb3c-8ffa-98b63f3bf3a3"],"request-id":["647a2bdb-7a39-cb3c-8ffa-98b63f3bf3a3"],"X-FRAME-OPTIONS":["SAMEORIGIN"],"SPRequestDuration":["11"],"SPIisLatency":["0"],"Server":["Microsoft-IIS\/7.5"],"WWW-Authenticate":["Bearer realm=\"043a66d5-9a15-4b10-aa86-217119f4b03a\",client_id=\"00000003-0000-0ff1-ce00-000000000000\",trusted_issuers=\"00000005-0000-0000-c000-000000000000@*,00000003-0000-0ff1-ce00-000000000000@043a66d5-9a15-4b10-aa86-217119f4b03a\"","Negotiate","NTLM"],"X-Powered-By":["ASP.NET"],"MicrosoftSharePointTeamServices":["15.0.0.4771"],"X-Content-Type-Options":["nosniff"],"X-MS-InvokeApp":["1; RequireReadOnly"],"Date":["Mon, 24 Oct 2016 16:20:33 GMT"]} at Microsoft.Activities.Hosting.Runtime.Subroutine.SubroutineChild.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
We also see the following error in the event log on Workflow Manager servers:
Log Name: Application Source: Microsoft-SharePoint Products-SharePoint Foundation Date: 10/24/2016 6:09:00 PM Event ID: 8306 Task Category: Claims Authentication Level: Error Description: An exception occurred when trying to issue security token: ID3242: The security token could not be authenticated or authorized..
For some reason Security Token Service Application stops issuing tokens or the token gets expired.
Workaround 1:
Recycle SecurityTokenServiceApplicationPool pool in IIS, terminate and resubmit all Suspended workflows. It will solve the immediate problem. For how to find out all 2013 Workflow instances in Suspended Status see the SharePoint 2013 – List of 2013 Workflow Instances (Suspended, Canceled) blog post
Workaround 2:
While is not a permanent solution, it is more systematic workaround. It seems that Claims provider breaks when for some reason or other the App Pool “SecurityTokenServiceApplicationPool” account logs off unexpectedly. The solution is as suggested in the following blog: A COM+ application may stop working on Windows Server 2008 when the identity user logs off is to modify Local Group Policy setting ‘Do not forcefully unload the user registry at user logoff’ to not forcefully unload the registry and waits until no other processes are using the user registry before it unloads it.
“The policy can be found in the group policy editor (gpedit.msc)
Computer Configuration->Administrative Templates->System-> UserProfiles
Do not forcefully unload the user registry at user logoff
Change the setting from “Not Configured” to “Enabled”, which disables the new User Profile Service feature.
‘DisableForceUnload’ is the value added to the registry
Note issue applies happens on Vista, Windows 7 and Windows 2008 R2.”
That was another page in the Chronicles of SharePoint Bits, happy scripting!
How to find out the version of Workflow Manager components
For Workflow Manager Farm to function correctly all servers in the farm need to have the same version of DLLs installed. The bellow script will show version of Workflow Manager, Microsoft® Service Bus, Windows Fabric, and Workflow Manager Client installed on the server. It will check for both Service Bus version 1.0 and 1.1.
#################################################################################################### # # Author.......: David Shvartsman # Date.........: 10/14/2016 # Description..: Workflow Manager components versions # #################################################################################################### $VersionInfo = @() if (Test-Path "C:\Program Files\Workflow Manager\1.0\Workflow\Artifacts\Microsoft.Workflow.Service.dll") { $VersionInfo += (Get-ChildItem -Path "C:\Program Files\Workflow Manager\1.0\Workflow\Artifacts\Microsoft.Workflow.Service.dll").VersionInfo } if (Test-Path "C:\Program Files\Service Bus\1.1\Microsoft.ServiceBus.dll") { $VersionInfo += (Get-ChildItem -Path "C:\Program Files\Service Bus\1.1\Microsoft.ServiceBus.dll").VersionInfo } elseif (Test-Path "C:\Program Files\Service Bus\1.0\Microsoft.ServiceBus.dll") { $VersionInfo += (Get-ChildItem -Path "C:\Program Files\Service Bus\1.0\Microsoft.ServiceBus.dll").VersionInfo } if (Test-path "C:\Program Files\Windows Fabric\bin\FabricHost.exe") { $VersionInfo += (Get-ChildItem -Path "C:\Program Files\Windows Fabric\bin\FabricHost.exe").VersionInfo } if (Test-path "C:\Program Files\Reference Assemblies\Microsoft\Workflow Manager\1.0\Microsoft.Workflow.Client.dll") { $VersionInfo += (Get-ChildItem -Path "C:\Program Files\Reference Assemblies\Microsoft\Workflow Manager\1.0\Microsoft.Workflow.Client.dll").VersionInfo } CLS $VersionInfo | FT FileDescription, ProductName, ProductVersion
If you removed Workflow Manager make sure the following all the underlying directories are gone as well. The UnInstaller is infamous for it and the subsequent reinstall will fail.
That was another page in the Chronicles of SharePoint Bits, happy scripting!
Replace GlobalUserInterface.CompositeFont Manually
Manually replace corrupted font file with correct version.
cmd
as Administrator and navigate to %windir%\Microsoft.NET\Framework\v4.0.30319\WPF\Fonts and run:xcopy /y %USERPROFILE%\Downloads\GlobalUserInterface.CompositeFont .
(or copy and paste the GlobalUserInterface.Composite file through Windows Explorer to %windir%\Microsoft.NET\Framework\v4.0.30319\WPF\Fonts)
cmd
as Administrator and navigate to %windir%\Microsoft.NET\Framework64\v4.0.30319\WPF\Fonts and run:xcopy /y %USERPROFILE%\Downloads\GlobalUserInterface.CompositeFont .
(or copy and paste the GlobalUserInterface.Composite file through Windows Explorer to %windir%\Microsoft.NET\Framework64\v4.0.30319\WPF\Fonts).