<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1582555201946809839</id><updated>2011-10-06T00:20:06.277-07:00</updated><title type='text'>MOSS Junkie</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://mossjunkie.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1582555201946809839/posts/default'/><link rel='alternate' type='text/html' href='http://mossjunkie.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>MOSS Junkie</name><uri>http://www.blogger.com/profile/15084238615483044896</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1582555201946809839.post-3495259259971247601</id><published>2011-10-05T19:26:00.000-07:00</published><updated>2011-10-06T00:20:06.293-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Steve Jobs'/><category scheme='http://www.blogger.com/atom/ns#' term='Apple'/><title type='text'>RIP Steve Jobs - October 05, 2011</title><content type='html'>&lt;p&gt;I was never never a fan. I hated your guts. &lt;/p&gt;  &lt;p&gt;But looking back, I hated your guts because you never swayed. You stood firm in what you believed in. I could not. I am weak and come to think of it, the easiest thing for a weak person to do is envy the strong.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;I applaud you for what you did. You made technology cool.&lt;/strong&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1582555201946809839-3495259259971247601?l=mossjunkie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mossjunkie.blogspot.com/feeds/3495259259971247601/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1582555201946809839&amp;postID=3495259259971247601' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1582555201946809839/posts/default/3495259259971247601'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1582555201946809839/posts/default/3495259259971247601'/><link rel='alternate' type='text/html' href='http://mossjunkie.blogspot.com/2011/10/rip-steve-jobs-october-05-2011.html' title='RIP Steve Jobs - October 05, 2011'/><author><name>MOSS Junkie</name><uri>http://www.blogger.com/profile/15084238615483044896</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1582555201946809839.post-504593831225580817</id><published>2011-02-10T16:45:00.001-08:00</published><updated>2011-02-10T16:45:02.062-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Administration'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><category scheme='http://www.blogger.com/atom/ns#' term='Powershell'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint2010'/><title type='text'>Set-SPSite throws Object reference not set to an instance of an object error message</title><content type='html'>&lt;p&gt;&lt;strong&gt;Background:&lt;/strong&gt; Recently I moved some content databases from one farm to another. The only major difference between the content databases’ source web application and destination web application was the authentication provider. The source had &lt;strong&gt;Classic Authentication&lt;/strong&gt; and the destination farm’s web application had &lt;strong&gt;Claims Based Authentication&lt;/strong&gt;. Both the farms were in the same domain.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Issue:&lt;/strong&gt; After moving the databases, I wanted to run some clean up tasks on the sites on the destination server. One of the task was assigning the site new owner. While iterating the sites through PowerShell, and running &lt;strong&gt;Set-SPSite &lt;/strong&gt;cmdlet on it, I started seeing following&amp;#160; error message: &lt;/p&gt;  &lt;p style="line-height: normal; margin: 0in 0in 0pt" class="MsoNormal"&gt;&lt;span style="font-family: "&gt;&lt;font face="Arial"&gt;&lt;font style="font-size: 10pt" color="#800000"&gt;&lt;strong&gt;Set-SPSite : Object reference not set to an instance of an object.&lt;/strong&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: normal; margin: 0in 0in 0pt" class="MsoNormal"&gt;&lt;span style="font-family: "&gt;&lt;font face="Arial"&gt;&lt;font style="font-size: 10pt" color="#800000"&gt;&lt;strong&gt;At line:1 char:11&lt;/strong&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: normal; margin: 0in 0in 0pt" class="MsoNormal"&gt;&lt;strong&gt;&lt;font color="#800000"&gt;&lt;span style="font-family: "&gt;&lt;font face="Arial"&gt;&lt;font style="font-size: 10pt"&gt;+ Set-SPSite &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;#160; &lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 10pt"&gt;&lt;font face="Arial"&gt;http://&amp;lt;servername&amp;gt;/sites/&amp;lt;sitename&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Arial"&gt;&lt;font style="font-size: 10pt"&gt; -OwnerAlias &amp;quot;i:0#.w|domain&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: "&gt;&lt;font face="Arial"&gt;&lt;font style="font-size: 10pt"&gt;\siteadmin.user&amp;quot; -Verbose&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p style="line-height: normal; margin: 0in 0in 0pt" class="MsoNormal"&gt;&lt;span style="font-family: "&gt;&lt;font face="Arial"&gt;&lt;font style="font-size: 10pt" color="#800000"&gt;&lt;strong&gt;&amp;#160;&amp;#160;&amp;#160; + CategoryInfo&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; : InvalidData: (Microsoft.Share...SPCmdletSetSite:&lt;/strong&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: normal; margin: 0in 0in 0pt" class="MsoNormal"&gt;&lt;span style="font-family: "&gt;&lt;font face="Arial"&gt;&lt;font style="font-size: 10pt" color="#800000"&gt;&lt;strong&gt;&amp;#160;&amp;#160; SPCmdletSetSite) [Set-SPSite], NullReferenceException&lt;/strong&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: normal; margin: 0in 0in 0pt" class="MsoNormal"&gt;&lt;span style="font-family: "&gt;&lt;font face="Arial"&gt;&lt;font style="font-size: 10pt" color="#800000"&gt;&lt;strong&gt;&amp;#160;&amp;#160;&amp;#160; + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletSetSite&lt;/strong&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: normal; margin: 0in 0in 0pt" class="MsoNormal"&gt;&lt;span style="font-family: "&gt;&lt;strong&gt;&lt;font color="#800000" size="2" face="Arial"&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/span&gt;&amp;#160;&lt;/p&gt;  &lt;p style="line-height: normal; margin: 0in 0in 0pt" class="MsoNormal"&gt;&lt;a href="http://lh4.ggpht.com/_oAw4OaxR8iU/TVSGiIC321I/AAAAAAAAL18/DhXEcJwNe1U/s1600-h/clip_image001_thumb%5B2%5D%5B2%5D.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image001_thumb[2]" border="0" alt="clip_image001_thumb[2]" src="http://lh3.ggpht.com/_oAw4OaxR8iU/TVSGjCFGW4I/AAAAAAAAL2A/Kw8cI5WVGT4/clip_image001_thumb%5B2%5D_thumb.jpg?imgmax=800" width="430" height="148" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Resolution&lt;/strong&gt;: After trying various options (backup-restore/detach-attach/recreate the web application, etc), I tried remounting database to see if it’ll fix the entries and voila it started working!&lt;/p&gt;  &lt;p&gt;&lt;font color="#008040"&gt;Dismount-SPContentDatabase&lt;/font&gt; &lt;font color="#0000ff"&gt;-Identity&lt;/font&gt; &amp;lt;databasename&amp;gt;     &lt;br /&gt;&lt;font color="#008000"&gt;Mount-SPContentdatabase&lt;/font&gt; &amp;lt;databasename&amp;gt; &lt;font color="#0000ff"&gt;-WebApplication&lt;/font&gt; http://&amp;lt;webappurl&amp;gt;    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;Hope this helps!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1582555201946809839-504593831225580817?l=mossjunkie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mossjunkie.blogspot.com/feeds/504593831225580817/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1582555201946809839&amp;postID=504593831225580817' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1582555201946809839/posts/default/504593831225580817'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1582555201946809839/posts/default/504593831225580817'/><link rel='alternate' type='text/html' href='http://mossjunkie.blogspot.com/2011/02/set-spsite-throws-object-reference-not.html' title='Set-SPSite throws Object reference not set to an instance of an object error message'/><author><name>MOSS Junkie</name><uri>http://www.blogger.com/profile/15084238615483044896</uri><email>noreply@blogger.com</email></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_oAw4OaxR8iU/TVSGjCFGW4I/AAAAAAAAL2A/Kw8cI5WVGT4/s72-c/clip_image001_thumb%5B2%5D_thumb.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1582555201946809839.post-4819890904141598945</id><published>2011-01-25T07:09:00.000-08:00</published><updated>2011-01-26T07:46:45.707-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sandbox'/><category scheme='http://www.blogger.com/atom/ns#' term='Site Template'/><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><category scheme='http://www.blogger.com/atom/ns#' term='template'/><category scheme='http://www.blogger.com/atom/ns#' term='Powershell'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint2010'/><category scheme='http://www.blogger.com/atom/ns#' term='SiteCollection'/><title type='text'>Using powershell to create site collections from custom web template</title><content type='html'>Recently we wanted to create multiple site collections from site templates. This was a pretty easy thing to do in SharePoint 2007 – save site as template .stp add the template using CA and you are ready to churn out site collections using the template. The process changed in SharePoint 2010. The "save site as template" now saves it as a web solution package (.wsp) and is now treated as any other wsp in SP2010 world. You have to add the solution and then deploy it. Unfortunately, this is not it. You have to either follow a whole lot of manual steps or achieve this programatically.&lt;br /&gt;&lt;br /&gt;Here’s an excellent article that provides manual steps on &lt;a href="http://msadvisor.wordpress.com/2010/02/05/implementing-site-templates-on-sharepoint-2010/"&gt;Implementing Site Templates on SharePoint 2010&lt;/a&gt;. &lt;br /&gt;I found an excellent article to achieve this programatically: &lt;a href="http://blog.mastykarz.nl/programmatically-creating-sites-site-collections-custom-web-template/"&gt;Programmatically creating Sites and Site Collections from a Custom Web Template&lt;/a&gt;&lt;br /&gt;I pretty much used the above blog by &lt;a href="http://blog.mastykarz.nl/"&gt;Waldek Mastykarz&lt;/a&gt; and created a powershell script version for you any one interested:&lt;br /&gt;&lt;span class="Apple-style-span" style="color: green;"&gt;######start script############&lt;/span&gt;&lt;br /&gt;&lt;span style="color: green;"&gt;#&lt;/span&gt;&lt;span style="color: green;"&gt;####### Initialize variables ##########&lt;/span&gt;     &lt;br /&gt;&lt;span style="color: purple;"&gt;$webApp&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;http://clientcompany/&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$ownerAlias&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;domain\sitecollectionOwner&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$projDB&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;clientcompany_proj_Content&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$deptDB&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;clientcompany_dept_Content&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$deptQuota&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Departments Site&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$funcQuota&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Functional Site&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$projQuota&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Projects Site&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$solutionPath&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;C:\Clients\ClientCompany\CODE\SiteTemplates\&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$projSolutionName&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Project Team Site.wsp&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$funcSolutionName&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Department Team Site.wsp&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$deptSolutionName&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Function Site.wsp&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$funcTemplateName&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Department Team Site&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$deptTemplateName&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Function Site&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$projTemplateName&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Project Team Site&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: green;"&gt;#&lt;/span&gt;&lt;span style="color: green;"&gt;####### AddInstallSolution function##########&lt;/span&gt;&lt;span style="color: green;"&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;function&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue;"&gt;AddInstallSolution&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;{       &lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;PARAM&lt;/span&gt;&lt;span style="color: black;"&gt;([&lt;/span&gt;&lt;span style="color: teal;"&gt;string&lt;/span&gt;&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;span style="color: purple;"&gt;$siteUrl&lt;/span&gt;&lt;span style="color: black;"&gt;, [&lt;/span&gt;&lt;span style="color: teal;"&gt;string&lt;/span&gt;&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;span style="color: purple;"&gt;$solutionName&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;span style="color: green;"&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;     &lt;br /&gt;&lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;write-host&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue; font-style: italic;"&gt;-ForegroundColor&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;DarkGreen&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;Adding&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;template&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;to&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;root&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;site&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;Add-SPUserSolution -LiteralPath &lt;/span&gt;&lt;span style="color: purple;"&gt;$solutionPath$solutionName&lt;/span&gt;&lt;span style="color: black;"&gt; -Site &lt;/span&gt;&lt;span style="color: purple;"&gt;$siteUrl&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;write-host&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue; font-style: italic;"&gt;-ForegroundColor&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;DarkGreen&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;Installing&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;template&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;solution&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;Install-SPUserSolution -Identity &lt;/span&gt;&lt;span style="color: purple;"&gt;$solutionName&lt;/span&gt;&lt;span style="color: black;"&gt; -Site &lt;/span&gt;&lt;span style="color: purple;"&gt;$siteUrl&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$solution&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; Get-SPUserSolution &lt;/span&gt;&lt;span style="color: purple;"&gt;$solutionName&lt;/span&gt;&lt;span style="color: black;"&gt; -Site &lt;/span&gt;&lt;span style="color: purple;"&gt;$siteUrl&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;do&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;{       &lt;br /&gt;&lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;write-host&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;waiting&lt;/span&gt;&lt;span style="color: black;"&gt; ...      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;Start-Sleep&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue; font-style: italic;"&gt;-Seconds&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: black;"&gt;5&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;}       &lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;until&lt;/span&gt;&lt;span style="color: black;"&gt; (&lt;/span&gt;&lt;span style="color: purple;"&gt;$solution&lt;/span&gt;&lt;span style="color: black;"&gt;.Status &lt;/span&gt;&lt;span style="color: red;"&gt;-eq&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Activated&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;)      &lt;br /&gt;&lt;br /&gt;}       &lt;br /&gt;&lt;/span&gt;&lt;span style="color: green;"&gt;#&lt;/span&gt;&lt;span style="color: green;"&gt;####### CreateSite function##########&lt;/span&gt;&lt;span style="color: green;"&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;function&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue;"&gt;CreateSite&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;{       &lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;PARAM&lt;/span&gt;&lt;span style="color: black;"&gt;([&lt;/span&gt;&lt;span style="color: teal;"&gt;string&lt;/span&gt;&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;span style="color: purple;"&gt;$siteUrl&lt;/span&gt;&lt;span style="color: black;"&gt;, [&lt;/span&gt;&lt;span style="color: teal;"&gt;string&lt;/span&gt;&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;span style="color: purple;"&gt;$siteName&lt;/span&gt;&lt;span style="color: black;"&gt;, [&lt;/span&gt;&lt;span style="color: teal;"&gt;string&lt;/span&gt;&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;span style="color: purple;"&gt;$templateName&lt;/span&gt;&lt;span style="color: black;"&gt;, [&lt;/span&gt;&lt;span style="color: teal;"&gt;string&lt;/span&gt;&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;span style="color: purple;"&gt;$dbName&lt;/span&gt;&lt;span style="color: black;"&gt;, [&lt;/span&gt;&lt;span style="color: teal;"&gt;string&lt;/span&gt;&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;span style="color: purple;"&gt;$quotaName&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;write-host&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: cadetblue; font-style: italic;"&gt;-ForegroundColor&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;DarkGreen&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;creating&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;site&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$siteName&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$solutionName&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;""&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;switch&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: purple;"&gt;$templateName&lt;/span&gt;&lt;span style="color: black;"&gt;)      &lt;br /&gt;{       &lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$deptTemplateName&lt;/span&gt;&lt;span style="color: black;"&gt; { &lt;/span&gt;&lt;span style="color: purple;"&gt;$solutionName&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$deptSolutionName&lt;/span&gt;&lt;span style="color: black;"&gt; }      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$projTemplateName&lt;/span&gt;&lt;span style="color: black;"&gt; { &lt;/span&gt;&lt;span style="color: purple;"&gt;$solutionName&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$projSolutionName&lt;/span&gt;&lt;span style="color: black;"&gt; }      &lt;br /&gt;}&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: black;"&gt;&lt;span style="color: green;"&gt;#create site using New-SPSite&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$site&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; New-SPSite &lt;/span&gt;&lt;span style="color: purple;"&gt;$siteUrl&lt;/span&gt;&lt;span style="color: black;"&gt; -Name &lt;/span&gt;&lt;span style="color: purple;"&gt;$siteName&lt;/span&gt;&lt;span style="color: black;"&gt; -OwnerAlias &lt;/span&gt;&lt;span style="color: purple;"&gt;$ownerAlias&lt;/span&gt;&lt;span style="color: black;"&gt; -ContentDatabase &lt;/span&gt;&lt;span style="color: purple;"&gt;$dbName&lt;/span&gt;&lt;span style="color: black;"&gt; -QuotaTemplate &lt;/span&gt;&lt;span style="color: purple;"&gt;$quotaName&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;&lt;span class="Apple-style-span" style="color: green;"&gt;#install wsp on the newly created site&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="color: black;"&gt;AddInstallSolution&amp;nbsp;&lt;/span&gt;&lt;span style="color: purple;"&gt;$siteUrl&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$solutionName&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;     &lt;span class="Apple-style-span" style="color: green;"&gt;#Get the template installed from the solution&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$webTemplates&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$site&lt;/span&gt;&lt;span style="color: black;"&gt;.RootWeb.GetAvailableWebTemplates(&lt;/span&gt;&lt;span style="color: black;"&gt;1033&lt;/span&gt;&lt;span style="color: black;"&gt;)      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$webTemplates&lt;/span&gt;&lt;span style="color: black;"&gt; | &lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;Where&lt;/span&gt;&lt;span style="color: black;"&gt; { &lt;/span&gt;&lt;span style="color: purple;"&gt;$_&lt;/span&gt;&lt;span style="color: black;"&gt;.Title &lt;/span&gt;&lt;span style="color: red;"&gt;-eq&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$templateName&lt;/span&gt;&lt;span style="color: black;"&gt; } | &lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;ForEach-Object&lt;/span&gt;&lt;span style="color: black;"&gt; { &lt;/span&gt;&lt;span style="color: purple;"&gt;$webTemp&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$_&lt;/span&gt;&lt;span style="color: black;"&gt; }      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: purple;"&gt;$webTemp&lt;/span&gt;&lt;span style="color: black;"&gt;)      &lt;br /&gt;{&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: black;"&gt;&lt;span class="Apple-style-span" style="color: green;"&gt;#we found the template - now let's apply it to the root web&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$web&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; Get-SPWeb &lt;/span&gt;&lt;span style="color: purple;"&gt;$siteUrl&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$web&lt;/span&gt;&lt;span style="color: black;"&gt;.ApplyWebTemplate(&lt;/span&gt;&lt;span style="color: purple;"&gt;$webTemp&lt;/span&gt;&lt;span style="color: black;"&gt;.Name)      &lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$web&lt;/span&gt;&lt;span style="color: black;"&gt;.Dispose()      &lt;br /&gt;}       &lt;br /&gt;&lt;/span&gt;&lt;span style="color: purple;"&gt;$site&lt;/span&gt;&lt;span style="color: black;"&gt;.Dispose()      &lt;br /&gt;}       &lt;br /&gt;&lt;span class="Apple-style-span" style="color: green;"&gt;#Create project team sites&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;write-host&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: black;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;. &lt;/span&gt;&lt;span style="color: maroon;"&gt;Creating&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;Project&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;team&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;sites&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;CreateSite &lt;/span&gt;&lt;span style="color: purple;"&gt;$webApp&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;projects/proj1&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Project 1&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$projTemplateName&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$projDB&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$projQuota&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;CreateSite &lt;/span&gt;&lt;span style="color: purple;"&gt;$webApp&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;projects/proj2&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Project 2&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$projTemplateName&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$projDB&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$projQuota&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;&lt;span class="Apple-style-span" style="color: green;"&gt;#Create department team sites&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: cadetblue; font-weight: bold;"&gt;write-host&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: black;"&gt;2&lt;/span&gt;&lt;span style="color: black;"&gt;. &lt;/span&gt;&lt;span style="color: maroon;"&gt;Creating&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;departmental&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;team&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;sites&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;CreateSite &lt;/span&gt;&lt;span style="color: purple;"&gt;$webApp&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;departments/HR&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Human Resources&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$deptTemplateName&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$deptDB&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$deptQuota&lt;/span&gt;&lt;span style="color: black;"&gt;      &lt;br /&gt;CreateSite &lt;/span&gt;&lt;span style="color: purple;"&gt;$webApp&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;departments/IT&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Information Technology&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$deptTemplateName&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$deptDB&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$deptQuota&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: green;"&gt;######end script############&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The script has a fairly simple logic&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Create a site by calling the local&amp;nbsp;&lt;span style="color: cadetblue;"&gt;CreateSite &lt;/span&gt;function with various parameters &lt;/li&gt;&lt;li&gt;&lt;span style="color: cadetblue;"&gt;CreateSite &lt;/span&gt;function creates a SharePoint site collection using New-SPSite cmdlet. &lt;/li&gt;&lt;li&gt;It then calls&amp;nbsp;&lt;span style="color: black;"&gt;&lt;span class="Apple-style-span" style="color: cadetblue;"&gt;AddInstallSolution&amp;nbsp;&lt;/span&gt;function to add the .wsp file into the site collection’s solution store and activate’s its feature.&lt;/span&gt; &lt;/li&gt;&lt;li&gt;&lt;span style="color: black;"&gt;&lt;/span&gt;&lt;span style="color: cadetblue;"&gt;CreateSite &lt;/span&gt;function then retrieves the site template from the newly activated feature and applies it to the root web of the site collection. &lt;span style="color: black;"&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;span style="color: black;"&gt;&lt;em&gt;Note: This is my first real world powershell script and I am not sure if I’ve followed the best practices and/or ps scripting standards for the above script.&lt;/em&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1582555201946809839-4819890904141598945?l=mossjunkie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mossjunkie.blogspot.com/feeds/4819890904141598945/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1582555201946809839&amp;postID=4819890904141598945' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1582555201946809839/posts/default/4819890904141598945'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1582555201946809839/posts/default/4819890904141598945'/><link rel='alternate' type='text/html' href='http://mossjunkie.blogspot.com/2011/01/creating-site-collections-from-custom.html' title='Using powershell to create site collections from custom web template'/><author><name>MOSS Junkie</name><uri>http://www.blogger.com/profile/15084238615483044896</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1582555201946809839.post-8959031207388560666</id><published>2009-07-10T16:18:00.001-07:00</published><updated>2009-07-10T16:33:55.573-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SPGroup'/><category scheme='http://www.blogger.com/atom/ns#' term='SPRoleAssignment'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><title type='text'>Create Custom SPGroup and assign Web and List</title><content type='html'>&lt;span xmlns=""&gt;&lt;p&gt;&lt;span class="Apple-style-span"   style="font-family:Arial, fantasy;color:#666666;"&gt;&lt;span class="Apple-style-span"  style="font-size:-webkit-xxx-large;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class="Apple-style-span"   style="font-family:Arial, fantasy;color:#666666;"&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Arial; color:#666666;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Wow! 3&lt;/span&gt;&lt;sup&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;rd&lt;/span&gt;&lt;/sup&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; blog in almost 2 years. Well here it is...&lt;br /&gt;The code below shows how to create a custom SPGroup and assign appropriate permissions on the site and list&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Arial; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;using (SPSite site = new SPSite("http://sitename"))&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;SPWeb web = site.AllWebs[0];&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial; color:#006600;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102); "&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;     &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;//use the web owner group as the owner for this new group&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;SPGroup groupOwner = web.SiteGroups.GetByID(int.Parse(web.Properties["vti_associateownergroup"]));&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;string groupName = "My Custom Group";&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;web.SiteGroups.Add(groupName, groupOwner, null, "Custom SharePoint Group for Demo");&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial; color:#006600;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102); "&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;     &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;//retrieve the newly added group to set roles for it&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;SPGroup wcmGroup = web.SiteGroups[groupName];&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial; color:#006600;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102); "&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;     &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;//get the designer role definition to assign to our custom group&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;SPRoleDefinition designerRoleDefinition = web.RoleDefinitions["Design"];&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial; color:#006600;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102); "&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;     &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;//assign designer role to our custom group at the web level&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;SPRoleAssignment roleAssignment = new SPRoleAssignment(wcmGroup);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;roleAssignment.RoleDefinitionBindings.Add(designerRoleDefinition);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;web.RoleAssignments.Add(roleAssignment);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;wcmGroup.Update();&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;SPList customList = web.Lists["CustomList"];&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial; min-height: 11.0px"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;if (!masterPageGallery.HasUniqueRoleAssignments)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;     &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;            &lt;/span&gt;&lt;span class="Apple-style-span" style="white-space: normal; "&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;masterPageGallery.BreakRoleInheritance(true);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="white-space: normal; "&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;      }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial; min-height: 11.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial; color:#006600;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102); "&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;     &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;//we have unique role assignments&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial; color:#006600;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102); "&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;     &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;//assign reader role to our custom group for the list&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;SPRoleDefinition readerRoleDef = web.RoleDefinitions.GetByType(SPRoleType.Reader);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;roleAssignment = new SPRoleAssignment(wcmGroup);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;roleAssignment.RoleDefinitionBindings.Add(readerRoleDef);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;customList.RoleAssignments.Add(roleAssignment);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;customList.Update();&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial; min-height: 11.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;web.Update();&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Arial"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 10.0px 0.0px; font: 12.0px Calibri; color:#666666;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p color="#666666" style="margin: 0.0px 0.0px 10.0px 0.0px; font: 12.0px Calibri; "&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Happy Coding!&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="font-family:Calibri, -webkit-fantasy;font-size:100%;"&gt;&lt;span class="Apple-style-span"  style="font-size:12px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1582555201946809839-8959031207388560666?l=mossjunkie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mossjunkie.blogspot.com/feeds/8959031207388560666/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1582555201946809839&amp;postID=8959031207388560666' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1582555201946809839/posts/default/8959031207388560666'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1582555201946809839/posts/default/8959031207388560666'/><link rel='alternate' type='text/html' href='http://mossjunkie.blogspot.com/2009/07/create-custom-spgroup-and-assign-web.html' title='Create Custom SPGroup and assign Web and List'/><author><name>MOSS Junkie</name><uri>http://www.blogger.com/profile/15084238615483044896</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1582555201946809839.post-409628905117018479</id><published>2007-12-21T11:34:00.001-08:00</published><updated>2007-12-21T11:45:00.919-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Publishing'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><category scheme='http://www.blogger.com/atom/ns#' term='MOSS'/><title type='text'>Access Denied error on enabling Office SharePoint Server Publishing Infrastructure</title><content type='html'>&lt;span xmlns=""&gt;&lt;p&gt;When trying to enable &lt;strong&gt;Office SharePoint Server Publishing Infrastructure&lt;/strong&gt; on a site created using team site (basically a WSS site), I got an &lt;strong&gt;Access Denied&lt;/strong&gt; error message. I found a very good blog by Vincent Rothwell - &lt;a href="http://blog.thekid.me.uk/archive/2007/02/05/activating-office-sharepoint-server-publishing-infrastructure-access-denied.aspx"&gt;Activating Office SharePoint Server Publishing Infrastructure - Access Denied&lt;/a&gt;. The steps require couple IIS resets and switching application pools - a daunting task if it's a live production environment.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Upon further investigation I found out that if no site collection on a web application is created with publishing feature, you cannot enable the Office SharePoint Server Publishing Infrastructure on a WSS Site (needs further validation). There is a simple workaround that has allowed us to enable Office SharePoint Server Publishing Infrastructure on our WSS site:&lt;br /&gt;&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Create a new site collection and use Publishing (Collaboration Portal) template at say: &lt;em&gt;http://&amp;lt;portalurl&amp;gt;/sites/test&lt;br /&gt;&lt;/em&gt;&lt;/li&gt;&lt;li&gt;Enable the &lt;strong&gt;Office SharePoint Server Publishing Infrastructure&lt;/strong&gt; on your required site collection&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Delete the temporary site.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;If I find more details on this, I will continue to add my findings.&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1582555201946809839-409628905117018479?l=mossjunkie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mossjunkie.blogspot.com/feeds/409628905117018479/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1582555201946809839&amp;postID=409628905117018479' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1582555201946809839/posts/default/409628905117018479'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1582555201946809839/posts/default/409628905117018479'/><link rel='alternate' type='text/html' href='http://mossjunkie.blogspot.com/2007/12/access-denied-error-on-enabling-office.html' title='Access Denied error on enabling Office SharePoint Server Publishing Infrastructure'/><author><name>MOSS Junkie</name><uri>http://www.blogger.com/profile/15084238615483044896</uri><email>noreply@blogger.com</email></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1582555201946809839.post-366206831245973816</id><published>2007-12-19T13:02:00.000-08:00</published><updated>2007-12-20T00:00:52.418-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><category scheme='http://www.blogger.com/atom/ns#' term='Document Library'/><category scheme='http://www.blogger.com/atom/ns#' term='Upload'/><category scheme='http://www.blogger.com/atom/ns#' term='MOSS'/><title type='text'>Uncheck "Add as a new version to existing files" checkbox on Upload.aspx in MOSS 2007</title><content type='html'>&lt;span style="color:#990000;"&gt;&lt;em&gt;Steps listed below require modifying the original MOSS files and may be unsupported. Be sure to backup original and modified files. &lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I was recently asked by my client to have the &lt;strong&gt;Add as a new version to existing files&lt;/strong&gt; option on the upload pages to be "unchecked" by default. This can come in handy on multiple file upload process. Multiple file upload process doesn't "complain" and silently overwrites or ignores existing files.&lt;br /&gt;&lt;br /&gt;Unlike v2/2003, this is very easy to do in MOSS/WSSv3:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Open the file &lt;strong&gt;Upload.aspx&lt;/strong&gt; in &lt;em&gt;C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\&lt;/em&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Locate following tag: &lt;em&gt;&lt;br /&gt;&amp;lt;asp:CheckBox id="OverwriteSingle" Checked="false" Text="&amp;lt;%$Resources:wss,upload_document_overwrite_file%&amp;gt;" runat="server" /&amp;gt;&lt;/em&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change Checked="true" to Checked="false"&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Do the same for the OverwriteMultiple tag:&lt;em&gt;&lt;br /&gt;&amp;lt;asp:CheckBox id="OverwriteMultiple" Checked="false" Text="&amp;lt;%$Resources:wss,upload_document_overwrite_version%&amp;gt;" runat="server" /&amp;gt;&lt;/em&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Save the file (no IISRESET needed)&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1582555201946809839-366206831245973816?l=mossjunkie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mossjunkie.blogspot.com/feeds/366206831245973816/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1582555201946809839&amp;postID=366206831245973816' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1582555201946809839/posts/default/366206831245973816'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1582555201946809839/posts/default/366206831245973816'/><link rel='alternate' type='text/html' href='http://mossjunkie.blogspot.com/2007/12/uncheck-add-as-new-version-to-existing.html' title='Uncheck &quot;Add as a new version to existing files&quot; checkbox on Upload.aspx in MOSS 2007'/><author><name>MOSS Junkie</name><uri>http://www.blogger.com/profile/15084238615483044896</uri><email>noreply@blogger.com</email></author><thr:total>3</thr:total></entry></feed>