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 will create my web and subwebs hierarchy from code. In past, in powershell i was using

new-SPWeb -url $trimmed -template "BLANKINTERNET#0" -language 1055 -useparenttopnav -name $name1

What is the object model equivalent of that powershell command. I want to create web from URL. So the site.Webs.Add is no suitable for me,i want to setup the hierarchy from URL. So the code below is not OK for me.

site.Webs.Add(
    txtSiteName.Text,
    txtSiteName.Text,
    Convert.ToUInt32(1033),
    site.WebTemplate,
    false,
    false
    );
share|improve this question
    
To be honest if you are running this locally, the object model is lacking in features for this and you are far better just calling stsadm for your needs, or even running the powershell from your code (Powershell is fully accessible) on a standard SharePoint installation. –  Hugh Wood Nov 28 '12 at 13:23
    
what do you mean running locally? i am running this code on the sharepoint server –  ozdogan Nov 28 '12 at 13:35
    
Do you want to run in it in page or in an application? –  Hugh Wood Nov 28 '12 at 13:36
    
does not matter.but now i am on a console application –  ozdogan Nov 28 '12 at 13:39
    
PowerShell ps = PowerShell.Create(); ps.AddScript("Add-PsSnapin Microsoft.SharePoint.Powershell"); or call STSADM which is my preference for the same thing, from the app. A long time ago after weeks of trying to write all deployment types with the OM I found out it isn't the same, and a little incomplete. –  Hugh Wood Nov 28 '12 at 13:46
add comment

1 Answer

up vote 1 down vote accepted

To be honest if you are running this locally, the object model is lacking in features for this and you are far better just calling stsadm for your needs, or even running the powershell from your code (Powershell is fully accessible) on a standard SharePoint installation.

so...

PowerShell ps = PowerShell.Create();
ps.AddScript("Add-PsSnapin Microsoft.SharePoint.Powershell"); 

or call STSADM which is my preference for the same thing, from the app. A long time ago after weeks of trying to write all deployment types with the OM I found out it isn't the same, and a little incomplete.

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.