Create a site collection with dedicated content db with the help of server object model

Hi,
 I have a requirement to implement a create a new site collection with dedicated content db. i have got 2 PowerShell scripts which does the same. first i will  create a content  db and then create the sitecollection with contentdb
parameter with the created contentdb name.
Now the site collection created must contain few doc libs and few splists with look up columns, people picker data type, multiline of text, single line of text,choice field. hence i am thinking the below approach:
 1) create a web template and include sp doclibs, splists , site columns in this.
 2) i am thinking of a ui design to create the below:
 These are called "projects" which is actually the site collection with the doclibs, splists and must be created by sharepoint admin on click of a link in my landing page.end users access these "projects"  aka 
"site collections" and uploads the documents into these projects and collaborate.
so my question is :  On click of a button can I create a site collection with a dedicated content db based on the web template created with the  hel of  server  object model?
The other approach is on click of this button call the power shell script which accepts the sitecollection name and contentdb name as parameter. is this possible in  server obj.model ?
passing a paramter from code behind- visual web part ui to power shell ?
and it should create the site collec based on the web template and create the content db.
my doubt #3 : will it not throw error "request timed out" when creating the site collec and contentdb from ui ?

Try below:
http://sharepoint.stackexchange.com/questions/21606/programmatically-create-a-site-collection-in-an-existing-mounted-content-databa
PowerShell is just a wrapper for the object model. You shouldn't need to reference PowerShell in your feature, just create the new site collection with C# inside your feature. There's a blog post here that illustrates some code that may get you started.
http://blog.mastykarz.nl/programmatically-creating-sites-site-collections-custom-web-template/
http://blogs.msdn.com/b/vesku/archive/2014/06/09/provisioning-site-collections-using-sp-app-model-in-on-premises-with-just-csom.aspx
# Enable the remote site collection creation for on-prem in web application level
# If this is not done, unknon object exception is raised by the CSOM code
$WebApplicationUrl = http://dev.contoso.com
$snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}
if ($snapin -eq $null)
Write-Host "Loading SharePoint Powershell Snapin"
Add-PSSnapin "Microsoft.SharePoint.Powershell"
$webapp=Get-SPWebApplication $WebApplicationUrl
$newProxyLibrary = New-Object "Microsoft.SharePoint.Administration.SPClientCallableProxyLibrary"
$newProxyLibrary.AssemblyName = "Microsoft.Online.SharePoint.Dedicated.TenantAdmin.ServerStub, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
$newProxyLibrary.SupportAppAuthentication = $true
$webapp.ClientCallableSettings.ProxyLibraries.Add($newProxyLibrary)
$webapp.Update()
Write-Host "Successfully added TenantAdmin ServerStub to ClientCallableProxyLibrary."
# Reset the memory of the web application
Write-Host "IISReset..."
Restart-Service W3SVC,WAS -force
Write-Host "IISReset complete."
If this helped you resolve your issue, please mark it Answered

Similar Messages

  • SharePoint 2010 - Create new site collection in existing web application with different existing content DB

    I have a SharePoint 2010 root level site collection SC1 in web application WEBAPP1. I want to create copy of that site collection in same web application WEBAPP1. Apart from Import/Export, Restore/Backup options, will following approach work? If yes , how?
    I took backup of content database of web application.
    Restored database with different name
    Mounted Content database to this WEBAPP1 by assigning new ID to DB
    Created new site collection by using this newly mounted DB
    Site collection gets created successfully but content does not appear.
    Please guide if i can achieve desired functionality by using this approach.
    If this helped you resolve your issue, please mark it Answered

    It is because the Site GUID is identical, and each GUID can only be present on the farm once. You can use Backup-SPSite/Restore-SPSite (which is full-fidelity, unlike Export-SPWeb/Import-SPWeb), which will generate a new GUID for the restore Site Collection,
    even in the same Web App.
    Trevor Seward
    Follow or contact me at...
    &nbsp&nbsp
    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

  • Alerts are not working for Site collections in a content database

    Hi,
    We have been into a strange issue that alerts are not working for site collections from a particular content database. When user subscribed for the alerts, they are getting mail about their subscription but not after that for any new items/documents added
    or changes happen in the list/document library.
    We have tried with Immediate as well as scheduled alerts both are not working.
    FYI, Alerts for all other site collections from different content database for the same web application are working without any issues.
    Any help would be appreciated.
    Thanks
    Ramkumar

    Looks like an Timer job Issue for your web application. Can you please check if these jobs are enabled and check error log for the alerts Timer jobs .Check whether the "Immediate Alerts" job is enabled for your web application.
    job-immediate-alerts
    job-daily-alerts
    job-weekly-alerts
    Please check this wiki -
    Troubleshooting Steps for SharePoint Alert Email Does Not Go Out
    Thanks
    Ganesh Jat [My Blog |
    LinkedIn | Twitter ]
    Please click 'Mark As Answer' if a post solves your problem or 'Vote As Helpful' if it was useful.

  • Error when trying to create a site collection

    Hi, 
    I receive the following error when trying to create a site collection in sharepoint 2013. Any ideas of what I can do to resolve?
    Sorry, something went wrong
    Failed to call GetTypes on assembly Microsoft.AnalysisServices.SharePoint.Integration, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91. Method 'ParseLogFileEntry' in type 'Microsoft.AnalysisServices.SharePoint.Integration.ConnectionUsageDefinition'
    from assembly 'Microsoft.AnalysisServices.SharePoint.Integration, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' does not have an implementation. Method 'ParseLogFileEntry' in type 'Microsoft.AnalysisServices.SharePoint.Integration.RequestUsageDefinition'
    from assembly 'Microsoft.AnalysisServices.SharePoint.Integration, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' does not have an implementation. Method 'ParseLogFileEntry' in type 'Microsoft.AnalysisServices.SharePoint.Integration.LoadUsageDefinition'
    from assembly 'Microsoft.AnalysisServices.SharePoint.Integration, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' does not have an implementation. Method 'ParseLogFileEntry' in type 'Microsoft.AnalysisServices.SharePoint.Integration.UnloadUsageDefinition'
    from assembly 'Microsoft.AnalysisServices.SharePoint.Integration, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' does not have an implementation.
    thanks,
    Sherazad

    Hi  ,
    Based on the error message, please check whether you have installed the spPowerPivot.msi add-in on each of your SharePoint server, and ran the configuration wizard, make sure that the powerpivotwebapplicationsolution.wsp
    is deployed correctly.
    Thanks,
    Eric
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Eric Tao
    TechNet Community Support

  • Creating new site collection using wsp template fails

    Hi all,
    I'm creating new site collections using a wsp solution generated by "save as template".
    For site collection creation I select "<Select template later>" then I upload the wsp solution.
    Everything worked until last month, now after CU installation (agoust 2014) I get an error:
    "List does not exist. The page you selected contains a list that does not exist. It may have been deleted by another user."
    Does anyone know how to solve it?
    Thanks 
    Maurizio

    ULS contains a lot of those errors:
    System.IO.FileNotFoundException: <nativehr>0x80070002</nativehr><nativestack></nativestack>, 
    StackTrace:
         in Microsoft.SharePoint.SPWeb.GetList(String strUrl)
         in Microsoft.SharePoint.SPWeb.TryGetListByUrl(String url)
         in Microsoft.SharePoint.SPFieldElement.PerformFixUpIfLookUpField(Guid fieldId, XmlNode xmlNodeOfAField, SPWeb web)
         in Microsoft.SharePoint.SPFieldElement.ElementActivated(SPFeaturePropertyCollection props, SPSqlCommand sqlcmdAppendOnly, SPWebApplication webApp, SPSite site, SPWeb webNull, Boolean fForce)
         in Microsoft.SharePoint.Administration.SPElementDefinitionCollection.ProvisionFieldsAndContentTypes(SPFeaturePropertyCollection props, SPSite site, SPWeb web, SPFeatureActivateFlags activateFlags, Boolean fForce)
         in Microsoft.SharePoint.Administration.SPElementDefinitionCollection.ProvisionElements(SPFeaturePropertyCollection props, SPWebApplication webapp, SPSite site, SPWeb web, SPFeatureActivateFlags activateFlags, Boolean fForce)
         in Microsoft.SharePoint.SPFeature.Activate(SPSite siteParent, SPWeb webParent, SPFeaturePropertyCollection props, SPFeatureActivateFlags activateFlags, Boolean fForce)
         in Microsoft.SharePoint.SPFeatureCollection.AddInternal(SPFeatureDefinition featdef, Version version, SPFeaturePropertyCollection properties, SPFeatureActivateFlags activateFlags, Boolean force, Boolean fMarkOnly)
         in Microsoft.SharePoint.SPFeatureCollection.AddInternalWithName(Guid featureId, Int32 compatibilityLevel, String featureName, Version version, SPFeaturePropertyCollection properties, SPFeatureActivateFlags activateFlags, Boolean force, Boolean
    fMarkOnly, Boolean fIgnoreMissing, SPFeatureDefinitionScope featdefScope)
         in Microsoft.SharePoint.SPFeatureManager.EnsureFeaturesActivatedCore(SPSite site, SPWeb web, String sFeatures, Boolean fMarkOnly, Boolean fIgnoreMissing)
         in Microsoft.SharePoint.SPFeatureManager.<>c__DisplayClass7.<EnsureFeaturesActivatedAtWeb>b__6()
         in Microsoft.SharePoint.SPSecurity.RunAsUser(SPUserToken userToken, Boolean bResetContext, WaitCallback code, Object param)
         in Microsoft.SharePoint.SPFeatureManager.EnsureFeaturesActivatedAtWeb(Byte[]& userToken, Guid& tranLockerId, Int32 nZone, Guid databaseid, Guid siteid, Guid webid, String sFeatures, Boolean fIgnoreMissing)
         in Microsoft.SharePoint.Library.SPRequestInternalClass.ApplyWebTemplate(String bstrUrl, String bstrWebTemplateContent, Int32 fWebTemplateContentFromSubweb, Int32 fDeleteGlobalListsWithWebTemplateContent, Int32 fIgnoreMissingFeatures, String&
    bstrWebTemplate, Int32& plWebTemplateId)
         in Microsoft.SharePoint.Library.SPRequestInternalClass.ApplyWebTemplate(String bstrUrl, String bstrWebTemplateContent, Int32 fWebTemplateContentFromSubweb, Int32 fDeleteGlobalListsWithWebTemplateContent, Int32 fIgnoreMissingFeatures, String&
    bstrWebTemplate, Int32& plWebTemplateId)
         in Microsoft.SharePoint.Library.SPRequest.ApplyWebTemplate(String bstrUrl, String bstrWebTemplateContent, Int32 fWebTemplateContentFromSubweb, Int32 fDeleteGlobalListsWithWebTemplateContent, Int32 fIgnoreMissingFeatures, String& bstrWebTemplate,
    Int32& plWebTemplateId)
         in Microsoft.SharePoint.SPWeb.ProvisionWebTemplate(SPWebTemplate webTemplate, String webTemplateToUse, SPFeatureWebTemplate featureWebTemplate, Page page, SPFeatureDependencyErrorBehavior featureDependencyErrorBehavior, ICollection`1&
    featureDependencyErrors)
         in Microsoft.SharePoint.SPWeb.ApplyWebTemplate(SPWebTemplate webTemplate, Page page, SPFeatureDependencyErrorBehavior featureDependencyErrorBehavior, ICollection`1& featureDependencyErrors)
         in Microsoft.SharePoint.SPWeb.ApplyWebTemplate(String strWebTemplate)

  • To create 3 diff files with same content but with diff names in same target

    Hi SapAll.
    i have got a a requirement where pi need to create 3 different files with same content but with different names under same target from a single Idoc.
    its an IDOC to 3 File Inteface.
    can any body help me in providing the differnt solutions for this without use of any script executions.
    will be waiitng for response.
    regards.
    Varma

    > i want to use only one communication channel to produce 3 different file names with same content ,so here i should use only one message mapping in 3 operation mappings .
    This is not possible to produce 3 different file names with single CC. You have to use 3 different CCs. unless you have going to use some other trick e.g some script to rename the file etc..
    As I suggested in my previous reply use Multi-Mapping Or create 3 different Interface Mappings (by using the same MM).
    Note: You have to create 3 different Inbound Message Interfaces (you can use the same Inbound Message Type) otherwise while creating the 3 Interface Determination it won't allow because of same Outbound & Inbound Message Interface. It will simply say Interface alreday exists..
    So, just use the Multi-Mapping which is best solution in my opinion, because the benefit of using multi-mapping are:
    1. You have to create only single Message Mapping
    2. Single Interface Mapping
    3. Single Receiver Determination
    4. Single Interface Determination
    5. 3 Receiver CCs (3 you have to use in any case)
    6. Performance wise it is good (read the blog's last 2 para)
    7. And last but not the least easy to maintain the scenario.

  • To create multiple files with same content but with different names

    Hi SapAll.
    here i have got a tricky situation on Idoc to File Scenario.
    in my interface of an Idoc to file ,there  is requirement to create multiple files with different file names but with same content based on one Idoc Segment.
    which means there will be one Zsegment with two fields in the idoc,where one field with (content refers to the name which file name should start with .so lets say if this segment is repeated for 3 times then PI should create 3 files in the same directory with same content but with different file names (from the filed).
    so here for now iam using one reciever file communication channel.
    can any body give me the quick answer.
    regards.
    Varma

    What do you mean by different names?
    when i make proper setting in the Receiver Channel....on how to create the filename (what to append) like add Timestamp, counter, date, messageid.....even in this case you will ahve file with different names and that too from same File channel.
    You can perform multi-mapping in XI/ PI and then your File channel will place the files in the target folder with relevant names. You cannot use Dynamic Configuration with Multi-Mapping!
    If you intend to use different File channels, then do the configuration as required (normal)...even over here you can follow multi-mapping.
    Do not use a BPM!
    Regards,
    Abhishek.

  • Can I create and manage collections in itunes instead of on the ipad?

    Can I create and manage collections in itunes instead of on the ipad? I have hundreds (maybe thousands) of PDF files for technical work items that I need to categorize and use on my ipad but it is a bit cumbersome to manually move them one at a time on the ipad.

    While you can add pdf files to iTunes it is not really intended to be used for organizing things other than a music collection.  It will only accept PDF files and media (audio, movie) files.  On the other hand if you can creatively come up with a way to make it work for you then go for it.

  • How can I add a hyperlink to a PDF with OSX 10.9? The "Help" article says to use the "add link" feature under "edit." It's not there.

    How can I add a hyperlink to a PDF with OSX 10.9? The "Help" article says to use the "add link" feature under "edit." It's not there. I could add links w/ the previous OS. Time sensitive project.

    Which application are you using?
    Clinton

  • Can we write client object model code with Server object model?

    Hi everyone,
    I have to create one timer job using client object model (C#) in Sharepoint 2010 template on feature activation. Is it possible to write the code of client object in sharepoint empty project to create timer job? If yes/no? then why?
    Thanks in advance!!!

    Hi ShindeK,
    Yes you can used CSOM in Sharepoint but Timer jobs run directly on the server. The Client Side Object Model is a wrapper that brokers its calls to the server via the built in web services that SharePoint provides.
    You will not get any performance gains in this scenario using CSOM. You should use the full server object model of SharePoint
    SharePoint 2010 also has three Client Object Models (Managed, Silverlight, JavaScript) which are meant to be used by code accessing SharePoint remotely.
    --You can also used powershell script in timer job
    Chekc the link which cann help you step by step CSOM in Sharepoint timer job
    http://www.youtube.com/watch?v=Z7wHj-bSk0g
    You can also try the below link....
    https://bramdejager.wordpress.com/2013/08/02/using-csom-and-powershell-to-query-sharepoint-online-or-on-premise/
    http://stackoverflow.com/questions/3656920/run-sharepoint-timer-jobs-from-powershell
    Please mark the Answer and Vote me if you think that it will help you to resolved your issue

  • Creating site collection in claims enabled webapplication with each in seperate content database

    Hi All,
    We have a  requirement where end user have a option to create site collection with out contacting farm admin, and each site collection would be created in separate content db.
    we used WebApplication.sites.add() which is working only for classic authentication web applications.
    how do we create site collections in claims enable web application with each site in separate content db?
    Any thoughts on this would be helpful.
    ragava_28

    Hi,
    We can use Self Service Site Creation to achieve your requirement.
    The code snippet below for your reference:
    using (var site = rootSite.SelfServiceCreateSite(siteCollectionUrl, title, description, locale, null, adminLogin, adminName, adminEmail, secondaryAdminLogin, secondaryAdminName, secondaryAdminEmail))
    var web = site.RootWeb;
    web.AllowUnsafeUpdates = true;
    //Activate web template feature
    site.Features.Add(webTemplateFeatureGuid);
    //Apply web Template
    using (var s = new SPSite(site.ID))
    var webTemplates = s.RootWeb.GetAvailableWebTemplates(locale);
    var webTemplateId = "{" + webTemplateFeatureGuid.ToString() + "}#" + webTemplateName;
    var webTemplate = webTemplates[webTemplateId];
    if (webTemplate != null)
    web.ApplyWebTemplate(webTemplate);
    // need to reload web. Features in webtemplate have modified it!
    web = site.OpenWeb(web.ServerRelativeUrl);
    // Continue doing stuff to new site
    Here is a similar thread for your reference:
    http://sharepoint.stackexchange.com/questions/26303/unable-to-create-site-collection-programmatically
    Best Regards
    Dennis Guo
    TechNet Community Support

  • Crawl Rule for Crawling Specific Page across all the site collection under one content source

    I have a MOSS 2007 web Application added to SharePoint 2010 Search Service Application Content Source, which is having 50+ Site Collections which follows same template. Every Site collection having one CustomPages Library and CustomPage.aspx. 
    If search Service would like to crawl only CustomPage.aspx from all the site collection under the web application, what would be the Path or Regular expression while creating the Crawl Rule. 
    i have given the path as  http://webapplication/sites/*/CustomPages/CustomPage.aspx, but this is not working. Can anyone help me out with correct path or regular expression in this case.
    Thanks..

    To crawl that page you'd also need to crawl the pages beneath it, otherwise SharePoint will never get to the page to check if it matches a rule. I assume you have some other rules that are blocking the rest of the content of the site?
    Try adding another rule that allows http://webapplication/sites/* then have your include rule beneath that and another exclude rule for
    http://webapplication/sites/*/* beneath that. That should eliminate nearly all the other content and provide you with your custompage.aspx results.

  • Create new site collection but page cannot be dislayed

    Hi all,
    im pretty new when it comes to Sharepoint.So far installation was successfull and i can access central administration page.
    I then changed Alternate access mapping from http://intra01/ (intra01 was probably addes,since computer has this name during setup)  to http://intra
    When i click the link,i only get this page cannot be displayed.
    When i created two new site collections,it is shown as http://intra/sites/main (where main was the name i gave for first site collection).
    When i click the link,i only get this page cannot be displayed.Same is for 2nd site i created.
    When i change Alternate access mapping for Central administration,this also fails and gives me page cannot be displayed.If i instead enter intra01,then i can access central administration.This does not work for the 2 site collection i created.
    What have i missed?
    thanks!
    Please mark as helpful if you find my contribution useful or as an answer if it does answer your question. That will encourage me - and others - to take time out to help you. Thank you! Off2work

    Hi
    let me split the issue
    <<I then changed Alternate access mapping from http://intra01/ (intra01 was probably addes,since
    computer has this name during setup)  to http://intra>>
    you are accessing your CA with http://intra1?
    and next you are trying to access it using http://intra?
    Did you installed CA on port 80?
    Anyway, please check if you can resolve the new name used in AAM , intra.
    If you can't please check your DNS configuration
    Come back with results and details. thanks
    Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

  • How to programmatically create a site column and a content type

    Hello,
    I'd like to create a site column (let's say a field text) and a content type, only  using c#  -i.e. I don't want to add new item/column and then xml. This code will be added to a FeatureActivated.My code is :
    public override void FeatureActivated(SPFeatureReceiverProperties properties) {SPWeb rootweb = (SPWeb) properties.Feature.Parent;
    SPFieldText field = new SPFieldText(SPfiledscollection???, "field1");
    if (field != null)
    rootweb.Fields.Add(field)
    rootweb.Update();
    }   SPContentType newContentType = new SPContentType(spcntenttypeId??, SPContentTypeCollection ??, "content1");
       rootweb.ContentTypes.Add(newContentType);
       rootweb.Update();
    Are there any sample codes out there? I've only found samples using xml - which has an irritating "feature"
    Thank you
    Christos

    Nice code and it helped me understand. Some small questions. I'm trying to make all the "data" for a (sub)web site.
    So, I think, my steps are:
    1. create site columns+content type
    2. create  list
    3. create a lookup site column that uses the list on <2>
    4. create content type that uses the site column on <3>
    5. Create the list for the content type on <4>
    My confusion is: should I use one feature for everything? Your code is using scope=site, so i need to "hardcode" the web site's name. I don't mind doing that , I just don't know how to use scopes in features for creating data.
    Thank you
    Christos

  • I want to bind my client certificate with machine certificate in order to bind user with dedicated one machine. Kindly help

    I have created one dedicated root CA for domain and auto enrollment has been enabled through Group Policy.
    I want to bind my client certificate with machine certificate in order to bind user with dedicated with one machine. In order to prevent duplicate logins

    Hi,
    How about using
    User Rights Assignment?
    You can deny all other users’
    log on locally right on the machine.
    User Rights Assignment
    http://technet.microsoft.com/en-us/library/cc780182(v=WS.10).aspx
    Best Regards,
    Amy Wang

Maybe you are looking for

  • Setup google calendar in calendar

    We have 2 step verification setup on my wife's macbook. Is there some special we need to do in Calendar to get it to sync with google calendar?

  • Control Design and Simulation palette doesn't appear

    I'm using LabVIEW 2009 in Professional License. I've installed Control Design and Simulation Module with its all other required Toolkits. The problem is that Control Design and Simulation palette  doesn't appear in the Functions Palette in any VI. Pl

  • Interface Failing when ever we do maintanace!

    Dear All, We are facing a Big problem everytime in our prduction server please help! Problem:  SENDER SERVER:RFC          RECEIVER SERVER: IDOC       MIDDLEWARE:+XI 3.0 with latest patch+ Every week when ever we restart our Receiver Server (for maint

  • Mapping a Font into JVM

    Hi folks! First of all, excuse me because of my poor English. Now I am going to explain you the heart of the problem: I must map "Verdana" font (that is available in all of Window OSes, so it's not by default included into any JVM) so I can use this

  • 10.5.3 Troubles Galore

    Boy, what nightmare this latest update to 10.5.3 has caused! iMac G5 Trouble: 1) The LaCie 500GB USB drive that I used with Time Machine no longer shows up on the desktop. (already tried trashing the "apple.finder.plist file" from my home directory,