<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>_cyclops_'s blog &#187; Work &gt; PowerShell</title>
	<atom:link href="http://cyclops.nettrends.nl/blog/category/work-powershell/feed/" rel="self" type="application/rss+xml" />
	<link>http://cyclops.nettrends.nl/blog</link>
	<description>Bloggin' my world....</description>
	<lastBuildDate>Sat, 21 Jan 2012 08:23:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Creating a subsite using the client side object model in SharePoint 2010</title>
		<link>http://cyclops.nettrends.nl/blog/2010/04/creating-a-subsite-using-the-client-side-object-model-in-sharepoint-2010/</link>
		<comments>http://cyclops.nettrends.nl/blog/2010/04/creating-a-subsite-using-the-client-side-object-model-in-sharepoint-2010/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 18:36:26 +0000</pubDate>
		<dc:creator>Ruben</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[Work > PowerShell]]></category>
		<category><![CDATA[Work > SharePoint]]></category>
		<category><![CDATA[Work > SharePoint 2010]]></category>

		<guid isPermaLink="false">http://cyclops.nettrends.nl/blog/?p=221</guid>
		<description><![CDATA[We&#8217;ve all seen loads of things to you can so with the new Client Side Object Model in SharePoint 2010. I&#8217;m personally loving it more and more! The only downside is, most examples and code is made to retrieve information. The object model can also be used to create things! Here&#8217;s a quick post on [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve all seen loads of things to you can so with the new <a href="http://msdn.microsoft.com/en-us/library/ee857094%28office.14%29.aspx">Client Side Object Model in SharePoint 2010</a>. I&#8217;m personally loving it more and more! The only downside is, most examples and code is made to retrieve information. The object model can also be used to create things!</p>
<p>Here&#8217;s a quick post on how we are creating subsites using the client side object model:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008000;">&#40;</span>ClientContext ctx <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> ClientContext<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;http://yoursite/&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
                WebCreationInformation wci <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> WebCreationInformation<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                wci<span style="color: #008000;">.</span><span style="color: #0000FF;">Url</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;YourSite&quot;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// Relative URL</span>
                wci<span style="color: #008000;">.</span><span style="color: #0000FF;">Title</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;YourSite&quot;</span><span style="color: #008000;">;</span>
                wci<span style="color: #008000;">.</span><span style="color: #0000FF;">Description</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Your nice description.&quot;</span><span style="color: #008000;">;</span>
                wci<span style="color: #008000;">.</span><span style="color: #0000FF;">UseSamePermissionsAsParentSite</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
                wci<span style="color: #008000;">.</span><span style="color: #0000FF;">WebTemplate</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;STS#0&quot;</span><span style="color: #008000;">;</span>
                wci<span style="color: #008000;">.</span><span style="color: #0000FF;">Language</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">1033</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">//LCID</span>
&nbsp;
                Web w <span style="color: #008000;">=</span> ctx<span style="color: #008000;">.</span><span style="color: #0000FF;">Site</span><span style="color: #008000;">.</span><span style="color: #0000FF;">RootWeb</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Webs</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>wci<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                ctx<span style="color: #008000;">.</span><span style="color: #0000FF;">ExecuteQuery</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>And that&#8217;s it :)</p>
<p>The WebTemplate might be a bit odd, check this PowerShell script to to retrieve the correct values you can enter. Also note, custom web templates are possible and are also retrieved using this PowerShell:</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008080; font-weight: bold;">PS</span> C:\Users\ruarco<span style="color: pink;">&gt;</span> <span style="color: #800080;">$s</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>SPSite<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;http://yoursite/&quot;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #008080; font-weight: bold;">PS</span> C:\Users\ruarco<span style="color: pink;">&gt;</span> <span style="color: #800080;">$s</span>.GetWebtemplates<span style="color: #000000;">&#40;</span><span style="color: #804000;">1033</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">select</span> Name<span style="color: pink;">,</span> Title</pre></div></div>

<p>Note the LCID in the <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsite.getwebtemplates.aspx">GetWebtemplates</a>. The select is handy because custom web templates get a long guid and you&#8217;ll only want to select Name at those things.</p>
]]></content:encoded>
			<wfw:commentRss>http://cyclops.nettrends.nl/blog/2010/04/creating-a-subsite-using-the-client-side-object-model-in-sharepoint-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

