SharePoint Server Migration : Lot of WebParts not found during Mount-SPContentDatabase (Error in ULS: “Safe mode did not start successfully”)

Today I’m preparing a migration of SharePoint Server 2016 to 2019. On-Premisses, of course.

Now I was ready to attach the old content databases. In doing so, I got an unexpected number of errors (actually with Test-SPContentDatabase):

Category        : MissingWebPart
Error           : True
UpgradeBlocking : False
Message         : WebPart class [d776845d-b1cd-923a-a779-01ecd8ef5bc6] (class [Microsoft.SharePoint.Portal.WebControls.SiteFeedWebPart] from assembly [Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]) is referenced 
                  [2] times in the database [ContentDatabase], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy          : One or more web parts are referenced in the database [ContentDatabase], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Locations       : 

Category        : MissingWebPart
Error           : True
UpgradeBlocking : False
Message         : WebPart class [b708fcb7-f3d7-5790-5692-03d08798aa5b] (class [Microsoft.SharePoint.Portal.WebControls.ProjectSummaryWebPart] from assembly [Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]) is 
                  referenced [1] times in the database [ContentDatabase], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy          : One or more web parts are referenced in the database [ContentDatabase], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Locations       : 

Category        : MissingWebPart
Error           : True
UpgradeBlocking : False
Message         : WebPart class [643e64f2-f484-0c7d-cbda-044ed3c44a46] (class [Microsoft.SharePoint.Portal.WebControls.MySharedContext] from assembly [Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]) is referenced 
                  [1] times in the database [ContentDatabase], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy          : One or more web parts are referenced in the database [ContentDatabase], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Locations       : 

Category        : MissingWebPart
Error           : True
UpgradeBlocking : False
Message         : WebPart class [70a3a34b-5605-b4b6-a17c-05d844c3c78d] (class [Microsoft.SharePoint.Portal.WebControls.FollowedCountsWebPart] from assembly [Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]) is 
                  referenced [1] times in the database [ContentDatabase], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy          : One or more web parts are referenced in the database [ContentDatabase], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Locations       : 

Category        : MissingWebPart
Error           : True
UpgradeBlocking : False
Message         : WebPart class [79bd35e7-9add-ed7f-9098-08ce54fcf2a7] (class [Microsoft.SharePoint.Portal.WebControls.SocialCommentWebPart] from assembly [Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]) is 
                  referenced [1] times in the database [ContentDatabase], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy          : One or more web parts are referenced in the database [ContentDatabase], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Locations       : 

Category        : MissingWebPart
Error           : True
UpgradeBlocking : False
Message         : WebPart class [3fbacd03-20cb-fbb9-8306-1ef66af965ec] (class [Microsoft.SharePoint.WebPartPages.GettingStartedWebPart] from assembly [Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]) is referenced [2] 
                  times in the database [ContentDatabase], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy          : One or more web parts are referenced in the database [ContentDatabase], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Locations       : 

Category        : MissingWebPart
Error           : True
UpgradeBlocking : False
Message         : WebPart class [4fd17205-2e2b-7562-486c-20bd9691bee7] (class [Microsoft.SharePoint.WebPartPages.AccessRequestsHideOldRequestsOnLoad] from assembly [Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]) is 
                  referenced [12] times in the database [ContentDatabase], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy          : One or more web parts are referenced in the database [ContentDatabase], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Locations       : 

Category        : MissingWebPart
Error           : True
UpgradeBlocking : False
Message         : WebPart class [058f341f-7b40-b2d6-8cda-21028ff4c6a1] (class [Microsoft.SharePoint.Portal.WebControls.TaggedPeopleListWebPart] from assembly [Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]) is 
                  referenced [1] times in the database [ContentDatabase], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy          : One or more web parts are referenced in the database [ContentDatabase], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Locations       : 

Category        : MissingWebPart
Error           : True
UpgradeBlocking : False
Message         : WebPart class [c01b6c09-055e-cb41-31be-24a416ce5049] (class [Microsoft.SharePoint.Portal.WebControls.TaggedUrlListWebPart] from assembly [Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]) is 
                  referenced [1] times in the database [ContentDatabase], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy          : One or more web parts are referenced in the database [ContentDatabase], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Locations       : 

Category        : MissingWebPart
Error           : True
UpgradeBlocking : False
Message         : WebPart class [c7060141-4bde-d951-d38c-456e813ef16c] (class [Microsoft.SharePoint.Portal.WebControls.ProfileManages] from assembly [Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]) is referenced 
                  [1] times in the database [ContentDatabase], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy          : One or more web parts are referenced in the database [ContentDatabase], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Locations       : 

Category        : MissingWebPart
Error           : True
UpgradeBlocking : False
Message         : WebPart class [ea9c1dd0-2027-3ab1-b0ee-48212f8d9179] (class [Microsoft.SharePoint.WebPartPages.BlogLinksWebPart] from assembly [Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]) is referenced [150] times 
                  in the database [ContentDatabase], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy          : One or more web parts are referenced in the database [ContentDatabase], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Locations       : 

Category        : MissingWebPart
Error           : True
UpgradeBlocking : False
Message         : WebPart class [d3ccbd27-51f0-eb57-a603-5556d226a05a] (class [Microsoft.SharePoint.WebPartPages.AccessRequestsCSRBridge] from assembly [Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]) is referenced [12] 
                  times in the database [ContentDatabase], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy          : One or more web parts are referenced in the database [ContentDatabase], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Locations       : 

Category        : MissingWebPart
Error           : True
UpgradeBlocking : False
Message         : WebPart class [7006b443-3b00-fe16-e42d-57927cc2be83] (class [Microsoft.SharePoint.Portal.WebControls.ProfileInfoWebPart] from assembly [Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]) is 
                  referenced [1] times in the database [ContentDatabase], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy          : One or more web parts are referenced in the database [ContentDatabase], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Locations       : 

Category        : MissingWebPart
Error           : True
UpgradeBlocking : False
Message         : WebPart class [b1297093-6459-24ae-d353-5955b4ae3817] (class [Microsoft.SharePoint.WebPartPages.BlogYearArchive] from assembly [Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]) is referenced [75] times in 
                  the database [ContentDatabase], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy          : One or more web parts are referenced in the database [ContentDatabase], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Locations       : 

Category        : MissingWebPart
Error           : True
UpgradeBlocking : False
Message         : WebPart class [b2922567-b718-19c2-0c2b-5b45ba6f4fb6] (class [Microsoft.SharePoint.Portal.WebControls.BlogView] from assembly [Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]) is referenced [261] 
                  times in the database [ContentDatabase], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy          : One or more web parts are referenced in the database [ContentDatabase], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Locations       : 

Category        : MissingWebPart
Error           : True
UpgradeBlocking : False
Message         : WebPart class [d6c8eb8f-cf28-daff-5b14-5edeab655f18] (class [Microsoft.Office.Server.Search.WebControls.AnalyticsHashTagWebPart] from assembly [Microsoft.Office.Server.Search, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]) 
                  is referenced [1] times in the database [ContentDatabase], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy          : One or more web parts are referenced in the database [ContentDatabase], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Locations       : 

Category        : MissingWebPart
Error           : True
UpgradeBlocking : False
Message         : WebPart class [2758321d-777a-1b90-79a1-696d87c1489b] (class [Microsoft.SharePoint.Portal.WebControls.ProjectSearchBrowseWebpart] from assembly [Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]) is 
                  referenced [520] times in the database [ContentDatabase], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy          : One or more web parts are referenced in the database [ContentDatabase], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Locations       : 

Category        : MissingWebPart
Error           : True
UpgradeBlocking : False
Message         : WebPart class [6d04058e-47c5-c17e-d161-720d39d0d03c] (class [Microsoft.SharePoint.Portal.WebControls.PeopleWebPart] from assembly [Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]) is referenced 
                  [1] times in the database [ContentDatabase], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy          : One or more web parts are referenced in the database [ContentDatabase], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Locations       : 

Category        : MissingWebPart
Error           : True
UpgradeBlocking : False
Message         : WebPart class [1c7111a3-2641-c283-6ced-92afa899c8bf] (class [Microsoft.SharePoint.Portal.WebControls.MySitePersonalSiteUpgradeOnNavigationWebPart] from assembly [Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, 
                  PublicKeyToken=71e9bce111e9429c]) is referenced [2] times in the database [ContentDatabase], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy          : One or more web parts are referenced in the database [ContentDatabase], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Locations       : 

Category        : MissingWebPart
Error           : True
UpgradeBlocking : False
Message         : WebPart class [43a3910c-1a88-b4e4-03af-a6a49d1c6a48] (class [Microsoft.SharePoint.Portal.WebControls.PublishedFeedWebPart] from assembly [Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]) is 
                  referenced [521] times in the database [ContentDatabase], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy          : One or more web parts are referenced in the database [ContentDatabase], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Locations       : 

Category        : MissingWebPart
Error           : True
UpgradeBlocking : False
Message         : WebPart class [7d38305c-72db-5f93-84c0-aa52134537df] (class [Microsoft.SharePoint.Portal.WebControls.SiteDocuments] from assembly [Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]) is referenced 
                  [1] times in the database [ContentDatabase], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy          : One or more web parts are referenced in the database [ContentDatabase], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Locations       : 

Category        : MissingWebPart
Error           : True
UpgradeBlocking : False
Message         : WebPart class [297bb5ba-8a6a-857a-b1ff-bef20d6fd130] (class [Microsoft.SharePoint.Portal.WebControls.MicroFeedWebPart] from assembly [Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]) is referenced 
                  [1] times in the database [ContentDatabase], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy          : One or more web parts are referenced in the database [ContentDatabase], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Locations       : 

Category        : MissingWebPart
Error           : True
UpgradeBlocking : False
Message         : WebPart class [ffdc5ac7-c118-e42d-79b6-c16470839314] (class [Microsoft.SharePoint.Portal.WebControls.TagInformationWebPart] from assembly [Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]) is 
                  referenced [1] times in the database [ContentDatabase], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy          : One or more web parts are referenced in the database [ContentDatabase], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Locations       : 

Category        : MissingWebPart
Error           : True
UpgradeBlocking : False
Message         : WebPart class [125081f0-f733-06c1-adbf-c8ac70f77368] (class [Microsoft.SharePoint.Portal.WebControls.SharedWithMeViewWebPart] from assembly [Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]) is 
                  referenced [260] times in the database [ContentDatabase], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy          : One or more web parts are referenced in the database [ContentDatabase], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Locations       : 

Category        : MissingWebPart
Error           : True
UpgradeBlocking : False
Message         : WebPart class [e85e13c0-9275-6d9e-eb9b-d99582fa6ad4] (class [Microsoft.SharePoint.Portal.WebControls.MySiteFirstRunExperienceWebPart] from assembly [Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, 
                  PublicKeyToken=71e9bce111e9429c]) is referenced [1] times in the database [ContentDatabase], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy          : One or more web parts are referenced in the database [ContentDatabase], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Locations       : 

Category        : MissingWebPart
Error           : True
UpgradeBlocking : False
Message         : WebPart class [39a4b0f2-ab3e-f990-3dcf-e1423f3fc5c1] (class [Microsoft.SharePoint.Portal.WebControls.PromotedSitesViewWebPart] from assembly [Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]) is 
                  referenced [260] times in the database [ContentDatabase], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy          : One or more web parts are referenced in the database [ContentDatabase], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Locations       : 

Category        : MissingWebPart
Error           : True
UpgradeBlocking : False
Message         : WebPart class [eab55457-f90a-9c12-d08c-e6bcf8e9cc08] (class [Microsoft.SharePoint.Portal.WebControls.AskMeAboutWebPart] from assembly [Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]) is 
                  referenced [1] times in the database [ContentDatabase], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy          : One or more web parts are referenced in the database [ContentDatabase], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Locations       : 

Category        : MissingWebPart
Error           : True
UpgradeBlocking : False
Message         : WebPart class [8f849c2c-345c-7fe5-e38c-ef599fc36fcf] (class [Microsoft.SharePoint.WebPartPages.AccessRequestsHideOldRequestsLink] from assembly [Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]) is 
                  referenced [12] times in the database [ContentDatabase], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy          : One or more web parts are referenced in the database [ContentDatabase], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Locations       : 

Please excuse the long list… It should make it clear that many standard web parts of SharePoint are affected here.

I have installed SharePoint Server 2019 in the last few days, including the latest updates:

During content database migration (Mount-SPContentDatabase) I saw this errors (and many more like this):

First:

Error: Failure in loading assembly: Microsoft.SharePoint.ApplicationPages, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c

Second:

Safe mode did not start successfully. Microsoft.SharePoint.WebPartPages.WebPartPageUserException: This page has encountered a critical error. Contact your system administrator if this problem persists.    
 at Microsoft.SharePoint.ApplicationRuntime.SafeControlsList.InitSafeControlsInfoFromConfig(Boolean inNonVRootAppDomain, SafeControlsContainer safeControlsContainer, SPWebApplication app, SPUrlZone zone)    
 at Microsoft.SharePoint.ApplicationRuntime.SafeControlsList..ctor(SPWebApplication app, SPUrlZone zone)    
 at Microsoft.SharePoint.ApplicationRuntime.SafeControls..ctor(SPWebApplication app, SPUrlZone zone)

Solution…

After a bit of thinking about the problem and some trial and error, it occurred to me that it might have something to do with the problem that was also described on Stefan Gossner’s blog:

See there! The errors I found are also described directly in the screenshot. Although I have been dealing with this problem over the last few days, I had forgotten that the Test-SPContentDatabase command is also affected, as Stefan writes.

So I reset the change in the web.config for each web application for the migration:

  <SafeControl Assembly="Microsoft.SharePoint.ApplicationPages, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" Namespace="Microsoft.SharePoint.ApplicationPages" TypeName="SPThemes" Safe="False" AllowRemoteDesigner="False" SafeAgainstScript="False" />

becomes…

  <SafeControl Assembly="Microsoft.SharePoint.ApplicationPages, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" Namespace="Microsoft.SharePoint.ApplicationPages" TypeName="SPThemes" Safe="True" AllowRemoteDesigner="False" SafeAgainstScript="False" />

Until there is an official fix, the “Safe” attribute should be set back to “False” after the migration and before going live. Although some PowerShell commands will then not work again, as described in Stefan’s blog.

Fix SharePoint Server (on-prem) Database Permissions using PowerShell

For some time now, when reinstalling SharePoint Server (2019 or Subscription Edition), I have noticed that after creating the ConfigDB and Central Administration content database, the next steps get stuck:


The farm is being upgraded in the timer service process. The task is 10.00% completed.

Here I’m running this script as as “second step” in farm configuration.

Add-PSSnapin Microsoft.Sharepoint.Powershell -ea 0

Get-SPFarm 

. psconfig.exe -cmd upgrade -inplace b2b


Initialize-SPResourceSecurity

Install-SPService

Install-SPFeature -AllExistingFeatures -Verbose

At some point I realized that SharePoint no longer copes well if an account other than the farm account is entered as DBO for a database. – This fails especially during updates.

Here is a script I use to fix the database permissions. It works generically. You don’t actually have to change anything.

Add-PSSnapin microsoft.sharepoint.powershell -ea 0

$SPFarmAccountName =  $farm.TimerService.ProcessIdentity.Username

Get-SPDatabase | % {
	$db = $_

	write-host "Check database '$($db.Name)'"

	$cnn = New-Object System.Data.SqlClient.SqlConnection
	$cnn.add_InfoMessage([System.Data.SqlClient.SqlInfoMessageEventHandler] {param($sender, $event);Write-Host $event.Message;}); 
	$cnn.FireInfoMessageEventOnUserErrors = $true
	$cnn.ConnectionString = $db.DatabaseConnectionString
	$cnn.Open()

	$cmd = New-Object System.Data.SqlClient.SqlCommand
	$cmd.Connection = $cnn
	$cmd.CommandTimeout = 7200
	$cmd.CommandText = "SELECT SUSER_SNAME(sid) as winloginname, * FROM sys.database_principals where (type='S' or type = 'U') and name='dbo'"
	$r = $cmd.ExecuteReader()

	$l = @()
	while($r.Read()) {
		$l += $r.GetString(0)
	}

	$currentDbo = $l | Select-Object -First 1

	write-host "`t current dbo: $currentDbo"

	$r.Close()
	$cmd.Dispose()

	if( $currentDbo -notlike "*$($SPFarmAccountName)*" ) {
		$cmd = New-Object System.Data.SqlClient.SqlCommand
		$cmd.Connection = $cnn
		$cmd.CommandTimeout = 7200
		$cmd.CommandText = @"
-- change database owner
EXECUTE AS LOGIN = '$($currentDbo)'
DROP SCHEMA IF EXISTS [$($SPFarmAccountName)];
DROP USER IF EXISTS [$($SPFarmAccountName)];
ALTER AUTHORIZATION ON DATABASE::[$($db.Name)] TO [$($SPFarmAccountName)];
REVERT               
"@
		$cmd.ExecuteNonQuery() | out-null

		$cmd = New-Object System.Data.SqlClient.SqlCommand
		$cmd.Connection = $cnn
		$cmd.CommandTimeout = 7200
		$cmd.CommandText = @"
-- take ownership
EXECUTE AS LOGIN = '$($SPFarmAccountName)'
DROP SCHEMA IF EXISTS [$($currentDbo)];
DROP USER IF EXISTS [$($currentDbo)];
CREATE USER [$($currentDbo)];
GRANT TAKE OWNERSHIP TO [$($currentDbo)];
ALTER ROLE [db_owner] ADD MEMBER [$($currentDbo)];
REVERT              
"@
		$cmd.ExecuteNonQuery() | out-null


		$cmd = New-Object System.Data.SqlClient.SqlCommand
		$cmd.Connection = $cnn
		$cmd.CommandTimeout = 7200
		$cmd.CommandText = "SELECT SUSER_SNAME(sid) as winloginname, * FROM sys.database_principals where (type='S' or type = 'U') and name='dbo'"
		$r = $cmd.ExecuteReader()

		$l = @()
		while($r.Read()) {
			$l += $r.GetString(0)
		}

		$newDbo = $l | Select-Object -First 1

		write-host "`t new dbo: $newDbo"

		$r.Close()
		$cmd.Dispose()
	}

	$cnn.Close()
}

The currently set “DBO” will become a regular user of the database and member of role “db_owner”.

Push large repository to GitHub using PowerShell

To push a large repository to GitHub is’s one approach to do it step by step: Only some commits at a time.

Here is how I do it using Powershell:


$s = . git --no-pager log --all --no-abbrev-commit --pretty=format:%H,%S,%cI 

$s | % {
    $ps = $_.Split(",", [System.StringSplitOptions]::RemoveEmptyEntries)  

    $hash = $ps[0]
    $ref = $ps[1]
    $date = [datetime]::parse($ps[2])

    return (New-Object PSObject -Property @{
        Hash = $hash
        Ref = $ref
        Date = $date
    })
} | sort-object Date | where-object {$_.Ref -like "refs/heads/*" } | ForEach-Object {

    $ref = $_.Ref
    $date = $_.Date
    $hash = $_.Hash


    write-host "Branch: $ref  Date: $($date)"

    $outp = . git push --no-verify github "$($hash):$($ref)"  2>&1

    if( $lastexitcode -ne 0 -and ($null -eq ($outp | ? { $_ -like "*branch tip is behind*"}))) {
    }

    $outp | write-host
}

The name of the remote respository is “github”.

This approach pushes each commit of the local repository to remote repo. It starts with the first commit.

Internal Server Error on SharePoint Server 2019 O-Premises after Update – Missing IIS Module “SPRequestFilterModule”.

Currently I investigate a problem. A SharePoint Server 2019 page showed me an Internal Server Error 500.

SharePoint Server 2019 is installed on Windows Server 2022. The August 2023 CU is applied.

After enabling “Failed Request Tracing” I saw this log message in “Failed Request Logs” on disk (C:\inetpub\logs\FailedReqLogFiles\W3SVCxxxxxxxx)

To enable “Failed Request Tracking”…

After I configured the “Failed Request Logging” I found a XML file on disk that is rendered as follows in the browser…

Now looking at the “Modules” config of the SharePoint web site in IIS I saw:

The module is missing…

I registered it by selecting the server level in the tree

Then… Open “Modules”

In the list the “SPRequestFilterModule” is missing:

On the right pane select “Configure Native Modules”:

Here the module is also missing

Now click “Register…”.

Add the module with name

SPRequestFilterModule

and Path

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\isapi\sprequestfilteringmodule.dll

Click on.

Try reloading the SharePoint page in browser. That’s it 🙂

I created this script to fix the issue:

$fn = "$([environment]::GetEnvironmentVariable("SystemRoot"))\system32\inetsrv\config\applicationhost.config"
$l = [System.Collections.Generic.List[string]]::new( ([system.io.file]::ReadAllLines($fn)) )

if( $null -eq ($l | ? { $_ -like "*SPRequestFilterModule*"} ) ) {
    Write-Host "SPRequestFilterModule not found..."

    if( (Test-Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\isapi\sprequestfilteringmodule.dll") ) {
        write-host "missing module found on disk!"

        . iisreset /stop

        $m = @()
        for( $i = 0; $i -lt $l.Count; $i++ ) {
            if( $l[$i].IndexOf("</globalModules>", [StringComparison]::OrdinalIgnoreCase) -ge 0) {
                $l.Insert($i, '            <add name="SPRequestFilterModule" image="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\isapi\sprequestfilteringmodule.dll" preCondition="bitness64" />')
                break
            }
        }

        [system.io.file]::WriteAllLines($fn, $l.ToArray())

        . iisreset /start
    } else {
        Write-Error "Missing module DLL not found on disk!"
    }
} else {
    Write-Host "SPRequestFilterModule is already registered in IIS!"
}

PS: I found an article on Microsoft Learning. There I will leave a comment on that topic.

https://learn.microsoft.com/en-us/answers/questions/1228993/recent-sp-security-update-causes-iis-to-throw-a-50

PowerShell >= 7 : Skip Certificate Check for Win and Linux

Here is a snippet of how to disable certificate checks on PowerShell 7 and above on Windows and Linux / Debian 11.

if ($PSVersionTable.PSEdition -eq 'Core') {
	$Script:PSDefaultParameterValues = @{
        "invoke-restmethod:SkipCertificateCheck" = $true
        "invoke-webrequest:SkipCertificateCheck" = $true
	}
} else {
	Add-Type @"
		using System.Net;
		using System.Security.Cryptography.X509Certificates;
		public class TrustAllCertsPolicy : ICertificatePolicy {
			public bool CheckValidationResult(
				ServicePoint srvPoint, X509Certificate certificate,
				WebRequest request, int certificateProblem) {
				return true;
			}
		}
"@

	[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
}

PowerShell on Linux / Debian 11 – Ctrl+C not working

I just found out that on my Debian 11 VM in PowerShell the key combination Ctrl+C does not work.

The script is not terminated by this, unlike expected.

I added the following code and now it works.

add-type -typedefinition @"
using System;
using System.IO;

public class CtrlCHandler
{
	public static void Main()
	{
		System.Console.CancelKeyPress += (s,e) => System.Diagnostics.Process.GetCurrentProcess().Kill();
	}
}
	
"@

[CtrlCHandler]::Main()

Blank / Empty pages when Accessing a Modern Experience page of SharePoint Server Subscription Edition

Resently I installed a new SharePoint Server Subscription Edition but in this case only with the latest security update (https://support.microsoft.com/en-us/kb/5002191).

When I opened the home page of the newly created root site collection everything seems fine. But when navigation to some link in the quick launch I only got empty / blank pages. No errors in the Developer tools. Just no content.

(There was almost no content in the HTML DOM. Just the <head> tag with some content and the <body> tag with 1 <script> tag…)

After searching in the SharePoint logs I found this error:

Error encountered when creating uri from baseUrl /_layouts/15/next/odspnext/.

It helped me to find this page of Stefan Goßner: https://blog.stefan-gossner.com/2021/09/29/trending-issue-_layouts-15-viewlsts-aspx-shows-as-blank-page-in-sp2019-after-installing-september-pu/

This information is about ShgarePoint 2019 but the message and even the error code is identical.

So I installed the lastest available “language dependent” patch of January 2022: https://support.microsoft.com/en-us/kb/5002110

After installing it and after running the config wizard all the pages contents are shown!

SharePoint User Information List URL (REMINDER)

This is the link to the SharePoint User Information List:

https://sharepoint.example.com/_catalogs/users/simple.aspx

The bold part must be replaced by the SharePoint site collection URL.

The interesting part is this: /_catalogs/users/simple.aspx

For example:

https://intranet.yourcompany.com/sites/finance/_catalogs/users/simple.aspx

/sites/finance is the site collection part of the URL in this case.

This list is a special system list but it’s based on the “normal” list mechanism of SharePoint. Therefore it has an ID and by knowing that you can open the settings page of the list.

If you opend the User Information List using the URL above in Firefox, Edge, Chrome,… you can select the surrounding table and grab the list ID from the HTML DOM:

With this ID you can open the settings page:

https://sharepoint.example.com/_layouts/15/listedit.aspx?List={F9780EA0-8B18-47E1-88BF-7C9543561C58}

Microsoft Teams App: Open Developer Tools

As widely known, Microsoft Teams runs on desktop computers with Windows OS or Mac OSX or Linux. The “Teams” app is based on “Electron” (https://www.electronjs.org).

“Electron” runs a packaged web technology based app inside a Chromium based application.

Microsoft Teams is such a “web technology based app” that runs in such a Chromium based application locally on a computer.

Chromium normally offers “Developer Tools” to dig into the HTML / CSS / Javascriptg of a w web technology based application.

Normally the “Developer Tools” are disabled in “Microsoft Teams”.

But there is a trick to enable the “Developer Tools” on “Microsoft Teams”:

1. Windows

(Left) click 7 or more times on the “Teams” icon besides the clock.

Now right-click the icon once. There you see the Developer Tools:

2. Mac OSX

It’s almost the same with Mac OSX: There you click the “Teams” icon in the tray 7 times.

(I’ll add a screenshot later.)

3. Linux

Not tested.