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 want to create a script with PowerShell and Webservices for a site collection admin. My plan is that site collection admin can use the script to create new SPWebs.

I don´t found any good examples and $webService.CreateWeb(OverloadDefinitions) is not working in my script. What are the overload parameters to create a ootb default teamsite? (Language id 1031 is the german id)

$urlSite = "http://mysharepoint.de/websites/sc"
$nameNewWeb = "Test1234"  

#################################################################

$urlSiteWebservice = $urlSite + "/_vti_bin/Sites.asmx"
$urlNameNewWeb = $urlSite + "/" + $nameNewWeb

$webService = New-WebServiceProxy $urlSiteWebservice -UseDefaultCredential

$webService.CreateWeb($urlNameNewWeb, $nameNewWeb, $nameNewWeb, "STS#0", "1031", $false, "1031", $false,
share|improve this question
    
Since you already are creating a a web service, why not just create the site collection directly in the web service via the SharePoint API rather than shell out to PowerShell? –  Dave Wise Mar 15 '12 at 15:17
    
Thanks for your commment! I don't completely understand your comment. I want to create the SPWeb from a normal client. That is the reason why I´m using the SharePoint Webservices with PowerShell. I think need only the correct overload and I´m fine. –  LaPhi Mar 15 '12 at 15:31

2 Answers 2

Try

$urlSite = "http://mysharepoint.de/websites/sc" 
$nameNewWeb = "Test1234"   

################################################################# 

$urlSiteWebservice = $urlSite + "/_vti_bin/Sites.asmx" 
$urlNameNewWeb = $nameNewWeb 

$webService = New-WebServiceProxy $urlSiteWebservice -UseDefaultCredential 
$webService.CreateWeb($urlNameNewWeb, $nameNewWeb, $nameNewWeb, "STS#0",1031, $true, 1031, $true, 1031, $true, $false, $false, $false, $false, $false, $false)

You'll get an exception about an error in the xml doc, but it should work

So my changes was relative url, language as int, true for language specified

share|improve this answer

A perhaps better approach would be to create an Application Page that creates the site for the user within SharePoint itself (rather than via powershell which will be hard to maintain over time) You could also include a link on the Site Settings page that would take users to your custom create site page.

However, to continue down the road you are on, you might need to look at the full signature of the CreateWeb() method. and make sure that your parameters are lining up. If they are lined up but you are still getting an error, can you post the error?

share|improve this answer

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.