Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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!

share|improve this question
    
What is the output from New-SPContentDatabase? There should be 4 properties it lists, Id, Name, Server, CurrentSiteCount. –  CMN Oct 5 '12 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? –  Per Jakobsen Oct 6 '12 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 Oct 10 '12 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 Oct 10 '12 at 13:46
    
Thanks for advice @CMN! Will try that! :=) –  Mattias Oct 10 '12 at 13:55
show 2 more comments

1 Answer

up vote 0 down vote accepted

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! :=)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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