I am quite new to Sharepoint and I have a question that has been bugging me for a few days now. I have a powershell script that is setting up some site collections in a Sharepoint webapplication I created. The following code should create a new content database with a given name. The content database is created, but it is not named the name I gave it. Instead it has given it a name with a guid.

Here is the code:

Write-Host "Create Content Database [" $groupDb "]  for " $groupRootUrl

New-SPContentDatabase -Name $groupDb -WebApplication $applicationRootUrl -WarningSiteCount 50 -MaxSiteCount 75 | Out-Null

Write-Host "Database Created"

As I understand New-SPContentDatabase command, it will create a new database. If you specify the parameter -name it will name the new database that name. For example: WSS_Content_Group1. If you leave it out it will create a name something like: WSS_Content_459f1985-2d80-4cfb-a678-befa22348098

As you can note in the codesnippet above I write out the name of the database and it is the right name. So the -name parameter should get a correct value. How ever the database is still given a name with a guid. I have tried to change -name to -databaseName as I read some where, but with no success.

I have tried to Google it but have not found any answers. My setting is Windows Server 2008 R2 (fresh install) and Sharepoint Server 2010 standalone (also fresh install). All service packs and updates are installed. It is installed in a VMware Workstation machine. Sharepoint only contains the webapplication where I want to set up these site collections.

So to summarize: Why does New-SPContentdatabase create database with guid instead of the name I give it?

Any answers that you have will be highly appreciated!

Friendly greetings from Mattias!

  • What is the output from New-SPContentDatabase? There should be 4 properties it lists, Id, Name, Server, CurrentSiteCount.
    – CMN
    Commented Oct 5, 2012 at 23:20
  • AFAIK New-SPContentDatabase doesn't contain the logic to add GUIDs to database names. Are you sure you're not looking at the database added by New-SPWebApplication or UI? Commented Oct 6, 2012 at 17:21
  • Sorry for late reply. Did not see your comments before now. @CMN: I am a bit new to this, so do not really know where I should see the output. There is no output in powershell with Id, Name, Server and CurrentSiteCount. Where would I find that? Per Jakobsen : The database is created, but with Guid-ending, when using code above. This causes a problem because the powershell script (which is in many ways not very good :=)) are looking for a database with the specific name. I think I might have found a solution to my specific problem. Will come back as soon as I have tested it. :=)
    – Mattias
    Commented Oct 10, 2012 at 13:01
  • If you remove the " | Out-Null" from the end of the New-SPContentDatabase you should see the output. The out-null actually hides the normal output.
    – CMN
    Commented Oct 10, 2012 at 13:46
  • also try with the very useful -whatif switch
    – Steve B
    Commented Oct 10, 2012 at 14:14

2 Answers 2


I came across the same issue. I deleted the contentdatabase with Microsoft SQL Server Management Studio. I deleted the physical database from the harddrive. Then I tried to create a contentdatabase again and it created a WSS_Content_459f1985-2d80-4cfb-a678-befa22348098.

By deleting the actual physical contentdatabase AND the logdatabase before creating the new contentdatabase, I managed to create it with the name I wanted. Maybe this helps.


Ok after a LOT of frustration :=) and googling I came across the solution by accidence. The powershell script I was running is not very good (not created by me of course ;=)). There is no error checking. First time running the script it works fine. But next time when it tries to create a database with same name, Sharepoint prevents naming conflict by adding a guid to the end of the new database. That causes the code that follow to fail, when it is going to create sitecollections, as it can not find a database with that name.

The confusing thing is that the database is removed from the database server in the code, and not visible there. So there really should not be any naming conflict causing the guids in the end. In my frustration I tried uninstalling Sharepoint (multiple times ;=)), but that did not solve the problem. Tried to create databases in UI, but same problem.

I found some scripts to change name of databases. That is when I realised that even when there was a fresh install of Sharepoint, old database files where still left in the Data folder (in my case: C:\Program Files\Microsoft Office Servers\14.0\Data\MSSQL10.SHAREPOINT\MSSQL\DATA ).

So to summarize: Even though I deleted databases from SQL Management Console, and uninstalled Sharepoint, the old databases were still there. So trying to create new database files with same name created the name conflict that resulted in guids in the end of database names. Hope this can save some one else from having to bang their heads for days! :=)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.