PowerShell for SharePoint (on-prem), SharePoint 2013, SharePoint 2016

Rename the Admin Content Database in SharePoint 2016 using PowerShell

If you’re like me and like to have “clean” names for your SharePoint databases, then you’d want to rename the Admin Content database in your SharePoint Server 2016 if you haven’t used a scripted installation.

The first time I installed SP2016 and used my script for SP2013 to rename the Admin Content database, I was faced with a strange red message on my PowerShell console!
The message would say “Move-SPSite Cannot complete the copy or merge operation because the database schema versions are different“.

In today’s blog post, we will see step-by-step how to counter the issue, and run the same PowerShell script just fine!

The full script is also available on my SharePoint Server GitHub Repository.


Check the Admin Content DB upgrade status

So we have this Admin Content DB with the ugly GUID, and we can’t handle it 🙂

Admin Content DB with GUID
  • Go to Central Admin
  • Under “Upgrade and Migration” >> Click on “Review database status
Review database status
Admin CDB status






If you try to rename the database now, it will fail, and Central Admin may not be accessible anymore.
OK, so we clearly need to do something…


Upgrade the Admin Content database

  • Open SharePoint Management Shell as Administrator (or PowerShell ISE + add snapin)
  • Type the following:
Get-SPWebApplication -Identity http://<site:port> | Get-SPContentDatabase
Get the Admin Content DB info

We’re going to need the Name for our next cmdlet, so let’s put it into a variable

Admin Content DB in a variable

Now let’s upgrade…. (Be aware this might take a while in some cases)

Upgrade-SPContentDatabase -Name $AdminCDBName -WebApplication http://<site:port>
Admin Content database upgraded!

Perfect! 🙂

  • Navigate back to Central Admin
  • Under “Upgrade and Migration” >> click on “Review database status
No action required for the Admin CDB


Rename the Admin Content database using PowerShell

Now it’s time to (finally) run the script to rename the database.
The script will be in full at the end of the post, and also available in my TechNet Gallery.

What does the script do?

  • Add the SharePoint Snapin
  • Grabs the old Admin Content database ID
  • Creates the new Admin Content database
  • Move the content from the old database to the new one (needs user confirmation)
  • Perform an IIS Reset
  • Remove the old Admin Content DB (needs user confirmation)
.\RenameAdminContentDB.ps1 -NewAdminDBName "<New_Name>" -CAUrl "http://<site:port>" -DBServer "<Server\Instance>"
PowerShell script run successfully!
Success in SQL Server


Full script

   This script renames the SharePoint Server Admin Content database.
   This script will rename the Admin Content database for your SharePoint Server 2013/2016 environment.

   **IMPORTANT FOR SP2016 **
   The Admin Content database will need to be upgraded first!!

   .\RenameAdminContentDB.ps1 -NewAdminDBName "<New_Name>" -CAUrl "http://<site:port>" -DBServer "<Server\Instance>"
   .\RenameAdminContentDB.ps1  (parameters are mandatory, and will be required if not entered initially)
    [Parameter(Mandatory=$true,HelpMessage="NEW name for the AdminContent database",Position=1)] 
    [Parameter(Mandatory=$true,HelpMessage="Current Central Admin URL (ex: http://<servername>:<port>)",Position=2)] 
    [Parameter(Mandatory=$true,HelpMessage="Current location of the AdminContent DB (ex: SQLServer\instance)",Position=3)] 
#Add SharePoint snapin
Write-Host "Adding SharePoint Snapin…" -f Yellow
Add-PSSnapin Microsoft.SharePoint.PowerShell

#Get "Id" of the current Admin Content DB (with GUID)
Write-Host "** Gathering the Id for OLD AdminContent DB... " -f Yellow
$OldId = (Get-SPWebApplication -Identity $CAUrl | Get-SPContentDatabase).Id

#Create new Admin Content DB and grab the Id
Write-Host "** Creating NEW Admin Content DB and grabbing the Id... Be patient." -f Yellow
New-SPContentDatabase -Name $NewAdminDBName -WebApplication $CAUrl -DatabaseServer $DBServer
$NewId = (Get-SPWebApplication -Identity $CAUrl | Get-SPContentDatabase | ? {$_.Name -eq "$NewAdminDBName"}).Id

#Move the content from OLD Admin DB to the NEW Admin DB
Write-Host "** Moving DB's..." -f Yellow
Get-SPSite -ContentDatabase $OldId | Move-SPSite -DestinationDatabase $NewId

#Resetting IIS
Write-Host "** Performing IISReset... " -f Yellow

#Removing the OLD Admin Content DB
Write-Host "** Removing OLD AdminContent DB..." -f Yellow
Remove-SPContentDatabase $OldId -Force
Write-Host "OLD AdminContent DB removed!" -f Green

#Checking the only Admin Content DB available
Write-Host "New Admin Content database: " -f Magenta
Get-SPWebApplication -Identity $CAUrl | Get-SPContentDatabase | Select Id, Name | Format-List



Loading Likes... Tagged , , ,

3 thoughts on “Rename the Admin Content Database in SharePoint 2016 using PowerShell

Comments are closed.