<?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>My SharePoint of View &#187; Script</title>
	<atom:link href="http://mysharepointofview.com/category/script/feed/" rel="self" type="application/rss+xml" />
	<link>http://mysharepointofview.com</link>
	<description>Thoughs from the field in SharePoint land</description>
	<lastBuildDate>Tue, 07 Dec 2010 17:04:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>A word about moving site collections</title>
		<link>http://mysharepointofview.com/2010/12/a-word-about-moving-site-collections/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-word-about-moving-site-collections</link>
		<comments>http://mysharepointofview.com/2010/12/a-word-about-moving-site-collections/#comments</comments>
		<pubDate>Tue, 07 Dec 2010 17:04:27 +0000</pubDate>
		<dc:creator>Mattias Karlsson</dc:creator>
				<category><![CDATA[How to]]></category>
		<category><![CDATA[Operation]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[MOSS]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Restore]]></category>
		<category><![CDATA[Site Collection]]></category>
		<category><![CDATA[STSADM]]></category>
		<category><![CDATA[WSS]]></category>

		<guid isPermaLink="false">http://mysharepointofview.com/?p=935</guid>
		<description><![CDATA[When the size of your site collections is increasing you sometimes have to move site collections around to put them in new content databases. There are a couple of different ways to perform a site collection move and I will try to cover some of them and end with a quite simple script that can [...]]]></description>
			<content:encoded><![CDATA[<p>When the size of your site collections is increasing you sometimes have to move site collections around to put them in new content databases. There are a couple of different ways to perform a site collection move and I will try to cover some of them and end with a quite simple script that can make the work even easier.</p>
<p>So the first one out is the simple <a title="Backup" href="http://technet.microsoft.com/en-us/library/cc263441(office.12).aspx">backup</a>/<a title="Restore" href="http://technet.microsoft.com/en-us/library/cc262087(office.12).aspx">restore </a>stsadm operations. The problem with this is that when doing the restore it&#8217;s not possible to specify what database to restore it to. So to be able to do this you need to lock the other content databases except the one you want to add it to. This might not be possible and the you could use a maintenance farm.</p>
<p>A much better option is the <a href="http://technet.microsoft.com/en-us/library/cc262923(office.12).aspx">mergecontentdbs </a>stsadm operation that was introduced in SP1 of Microsoft Office SharePoint Server 2007 and allows 3 different options. The first option only analyse the situation and calculate the amount of site collections in the content database and their size. The second option is to move all sites in the specified source content database and move them to the specified destination content database. Our last option is to use an xml file containing the sites that we want to move as an input file to the command and the operation will only move the sites specified in that xml-file</p>
<p>The best thing with the last option is that we can use the <a href="http://technet.microsoft.com/en-us/library/cc262492(office.12).aspx">enumsites</a> operation to get an xml file of all sites for our a specific web application.</p>
<pre>Example: stsadm -o enumsites -url [webAppUrl] -showlocks &gt; "D:tempsites.xml"</pre>
<p>The only problem with the above is that if you have a large amount of site collection and a number of content databases you will need to modify the list and remove the site collections that should not be moved to another content database. Later in this post I will show you how this problem can easily be addressed using PowerShell</p>
<p>Before using the mergecontentdbs operation you should consider two things. The first one is that since the mergecontentdbs operation is using the Content Deployment API it&#8217;s not suitable for sites larger then 10 GB. The other is that if content is changed during the operation you will not only risk losing the content but it could also cause database corruption as described in this KB: <a href="http://support.microsoft.com/kb/969242">http://support.microsoft.com/kb/969242</a>. So before moving the sites it&#8217;s a good recommendation to lock the site collections before the move.</p>
<p>To solve this I created a PowerShell script that does the following:</p>
<ol>
<li>Exports all the site collection for specific web application to an xml-file</li>
<li>Remove all sites in the file that is not located in the database I have specified</li>
<li>Sets the site collections to no access to prevent data loss</li>
<li>Move the sites from the source database to the destination database using the xml file</li>
<li>Offers you to make an IISreset on all WFEs in the farm (Recommended after the stsadm operation)</li>
<li>Set the site collection lock back to it&#8217;s original</li>
</ol>
<pre>$env:PATH = $env:PATH +
";C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions12BIN" 

$webAppUrl = "http://myWebAppUrl"
$sourceContentDB = "SourceContentDB"
$destinationContentDB = "DestinationContentDB"
$xmlfile = "d:tempsites.xml" 

# enumerate through all site collections and save them to the XML-file
Write-Host "Retreives all site collections located at"
$webAppUrl "and save it to " $xmlfile
stsadm -o enumsites -url $webAppUrl -showlocks &gt; $xmlfile | out-null 

# Import the XML file content $sites = [xml](Get-Content $xmlfile)
# Remove only the site collections located in the source database
Write-Host "Cleaning up the" $xmlfile "file and remove sites that should not be affected"
$sites.Sites.Site | Where-Object {$_.ContentDatabase -ne $sourceContentdb} |
ForEach-Object { $_.ParentNode.RemoveChild($_) | out-null } 

# Enumerate through all the sites in the xml file and make necessary preparations 

foreach($site in $sites.sites.site) {
# Lock the sites to prevent errors when migration and data loss
Write-Host "Locking the site" $site.url "to prevent data loss"
stsadm -o setsitelock -url $site.URL -lock Noaccess
} 

# Moving sites
stsadm -o mergecontentdbs -url $webAppUrl -sourcedatabasename $sourceContentDB
  -destinationdatabasename $destinationContentDB -operation 3 -filename $xmlfile 

# Get the farm object to find get all the WFEs in the farm
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local
Write-Host "To complete the move you need to make an IISreset on all WFEs in the farm"
Write-Host "You will now get the option to make an IISreset on all your WFEs"
Write-Host "" 

# Enumerate through all servers in the farm 

foreach ($svr in $farm.Servers) {
  foreach ($svc in $svr.ServiceInstances) {
    # If the server has the Windows SharePoint Services Web Application service it
    # is most likely it's a WFE.
    if($svc.TypeName -eq "Windows SharePoint Services Web Application"){
      # Ask if we should make an IISReset on the server
      $IISReset = Read-Host "Do you want to make an IIS-reset on"
      $svr.DisplayName "server (yes/No)?"
      if($IISReset.ToLower() -eq "yes") {
        iisreset $svr.DisplayName
      }
    }
  }
}
# Enumerate through all the sites in the xml file and finalize the move
foreach($site in $sites.sites.site) {
  # Set the original lockstate for the site collection
  Write-Host "Setting the original lock state for site" $site.url "to prevent data loss"
  stsadm -o setsitelock -url $site.URL -lock $site.Lock
}</pre>
<p>You can download the script [Download not found]. Just make sure you run it with an account that has sufficient permissions as described in the <a href="http://technet.microsoft.com/en-us/library/cc262923(office.12).aspx">enumcontentdbs</a> TechNet article and to modify the first 4 paramaters.</p>
<p>Another option to move site collections is to use the <a href="http://technet.microsoft.com/en-us/library/cc508852(office.12).aspx">Batch Site Manager</a> that is included in the <a href="http://technet.microsoft.com/en-us/library/cc508851(office.12).aspx">SharePoint Administration Toolkit</a>. This tool is packaged as a solution that you deploy to your farm. When deployed (and activated), it will then have a new option in Central Administration under Application Management.</p>
<p><a href="http://mysharepointofview.com/wp-content/uploads/2010/12/BatchSiteManager.jpg"><img class="alignnone size-full wp-image-948" title="BatchSiteManager" src="http://mysharepointofview.com/wp-content/uploads/2010/12/BatchSiteManager.jpg" alt="" width="420" height="57" /></a></p>
<p>The tool allows you to very nicely see all site collection for each content database, select the ones you want to move and create a timer job for the move. The Batch Site Manager is using the stsadm operations backup and restore in the background. It usually takes a bit longer then the mergecontentdbs but you get the option to specify when the timer job should be run, where to store the temporary file and you can get a email notification telling you the status of the move. As you can see in the screenshot above the tool also offers you to batch locking and deletion of sites.</p>
<p>The Batch Site Manager is recommended to use with sites up to 15 GB. The mentioned recommendations for the both tools should be seen as recommendation and it&#8217;s possible to test your way forward and what works in your environment.</p>
<p>So what about really large site collections?<br />
When moving really large sites none of the mentioned tools might work and you will then have to take on a different approach. In short this is what you need to do.</p>
<ol>
<li>Set the site collection that needs to be moved (farm 1) to read only and make a SQL backup of the content database (ContentDB A).</li>
<li>Restore the content database with a new name (ContentDB B) and attach it to your Maintanence farm (Farm B) or if you don&#8217;t have one to a different web application. Make sure you use the –assignnewdatabaseid since we will later on restore the database back to it&#8217;s original location</li>
<li>When it&#8217;s attached to farm B, use the <a href="http://technet.microsoft.com/en-us/library/cc261873(office.12).aspx">stsadm -deletesite</a> operation using the -gradualdelete parameter (introduced in the April CU) to remove the sites from ContentDB B that should not be moved.</li>
<li>Backup the ContentDB B and restore it (but don&#8217;t attach it yet) to your Farm A</li>
<li>Delete the large site from ContentDB A using stsadm and -gradualdelete.</li>
<li>When the site is deleted you can attach ContentDB A to Farm A</li>
<li>Unlock the site collection when done.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://mysharepointofview.com/2010/12/a-word-about-moving-site-collections/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disable or enable a health rule in SharePoint 2010 using PowerShell</title>
		<link>http://mysharepointofview.com/2010/11/disable-or-enable-a-health-rule-in-sharepoint-2010/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=disable-or-enable-a-health-rule-in-sharepoint-2010</link>
		<comments>http://mysharepointofview.com/2010/11/disable-or-enable-a-health-rule-in-sharepoint-2010/#comments</comments>
		<pubDate>Fri, 05 Nov 2010 15:28:53 +0000</pubDate>
		<dc:creator>Mattias Karlsson</dc:creator>
				<category><![CDATA[Script]]></category>
		<category><![CDATA[Health analyzer]]></category>
		<category><![CDATA[Health rule]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SharePoint 2010]]></category>

		<guid isPermaLink="false">http://mysharepointofview.com/?p=911</guid>
		<description><![CDATA[One really good new feature in SharePoint 2010 for us admins are the Health Analyzer. From a set of health rules the Health analyzer checks on  regular basis for problems or potential issues in your farm. SharePoint is shipped with a bunch of rules checking for instance things like disk space, if application pool accounts [...]]]></description>
			<content:encoded><![CDATA[<p>One really good new feature in SharePoint 2010 for us admins are the Health Analyzer. From a set of health rules the Health analyzer checks on  regular basis for problems or potential issues in your farm. SharePoint is shipped with a bunch of rules checking for instance things like disk space, if application pool accounts are in the local admin group, web.config settings etc. Some of these rules even offer the possibility to fix the problem automatically and it&#8217;s possible to build custom health rules.</p>
<p>In some scenarios these rules are not applicable for you. For instance you might know that you have a content database over the recommendation then you don&#8217;t want to get an alert every hour it is run. This can easily be changed from central administration but if you want to script it using PowerShell to build it into e.g. your installation script this is how you do.</p>
<p>Open up the SharePoint management shell.</p>
<p>First we need to connect to the list containing all the health rules. This is done from through the SPHealthReportsList class.</p>
<pre>$haList = [Microsoft.SharePoint.Administration.Health.SPHealthRulesList]::Local.Items</pre>
<p>Next thing we need to do is to get the ID of the specific rule. This can be done from Central Administration by clicking on an item. Right click on the page and take properties. In the Querystring in the Address field you will find the ID.</p>
<p>You can of course get the ID through PowerShell as well. The below line shows all the name of all items and their ID.</p>
<pre>$haList | Select-Object title, id | Format-List</pre>
<p>When you know the ID of the rule to disable (or enable) you simply get the item and set the HealthRuleCheckEnabled to True or False. When that is done we just update the item with the Update() method.</p>
<pre>$healthRule = $haList.GetItemById(1)
$healthRule["HealthRuleCheckEnabled"] = $false
$healthRule.Update()</pre>
<p>That&#8217;s all for today, hope you found it useful and now it&#8217;s time for weekend!</p>
]]></content:encoded>
			<wfw:commentRss>http://mysharepointofview.com/2010/11/disable-or-enable-a-health-rule-in-sharepoint-2010/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Quotas and locks for sandbox solutions</title>
		<link>http://mysharepointofview.com/2010/10/quotas-and-locks-for-sandbox-solutions/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=quotas-and-locks-for-sandbox-solutions</link>
		<comments>http://mysharepointofview.com/2010/10/quotas-and-locks-for-sandbox-solutions/#comments</comments>
		<pubDate>Mon, 25 Oct 2010 17:18:32 +0000</pubDate>
		<dc:creator>Mattias Karlsson</dc:creator>
				<category><![CDATA[How to]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Quota templates]]></category>
		<category><![CDATA[ResourceMeasures]]></category>
		<category><![CDATA[Sandbox]]></category>
		<category><![CDATA[SharePoint 2010]]></category>

		<guid isPermaLink="false">http://mysharepointofview.com/?p=893</guid>
		<description><![CDATA[When configuring Quota templates in SharePoint 2010 you will notice that a new section is added to the page. It&#8217;s called Sandbox solutions with Code Limits and is used to put a quota on sandbox solutions so that solutions that does not work properly will be shut down and not work when it reaches the maximum [...]]]></description>
			<content:encoded><![CDATA[<p>When configuring Quota templates in SharePoint 2010 you will notice that a new section is added to the page. It&#8217;s called <em>Sandbox solutions with Code Limits</em> and is used to put a quota on sandbox solutions so that solutions that does not work properly will be shut down and not work when it reaches the maximum daily quota. In this way we can limit sandbox solutions and protect our farm from poorly written code. As you can see on the screenshot below the values that should be specified (300 and 100 as default) are measured in points. So what is a point in this case? </p>
<p><a href="http://mysharepointofview.com/wp-content/uploads/2010/10/SandboxSolutionsQuotas.jpg"><img class="size-full wp-image-894 alignnone" title="SandboxSolutionsQuotas" src="http://mysharepointofview.com/wp-content/uploads/2010/10/SandboxSolutionsQuotas.jpg" alt="" width="527" height="91" /></a><a href="http://mysharepointofview.com/wp-content/uploads/2010/10/SandboxSolutionsQuotas.jpg"></a> </p>
<p>Microsoft has developed a way to calculate &#8220;problems&#8221;  within a solution based on a number of different metrics. To see what matrics are used you can use PowerShell and type the two following line of code in the <em>SharePoint 2010 Management Shell:</em> </p>
<pre>PS &gt; $spCodeService = [Microsoft.SharePoint.Administration.SPUserCodeService]::Local
PS &gt; $spCodeService.ResourceMeasures | select name</pre>
<pre>Name
----
AbnormalProcessTerminationCount
CPUExecutionTime
CriticalExceptionCount
IdlePercentProcessorTime
InvocationCount
PercentProcessorTime
ProcessCPUCycles
ProcessHandleCount
ProcessIOBytes
ProcessThreadCount
ProcessVirtualBytes
SharePointDatabaseQueryCount
SharePointDatabaseQueryTime
UnhandledExceptionCount
UnresponsiveprocessCount</pre>
<p>This will generate a list of all the Resource Measures. Each item has a number of properties that defines how the points should be calculated. If we take a closer look to the first item by typing: </p>
<pre>PS &gt; $spCodeService.ResourceMeasures["AbnormalProcessTerminationCount"]</pre>
<pre>MinimumThreshold                : 0
ResourcesPerPoint               : 1
AbsoluteLimit                   : 2
DiskSizeRequired                : 0
CanSelectForBackup              : False
CanRenameOnRestore              : False
CanSelectForRestore             : True
CanBackupRestoreAsConfiguration : True
Name                            : AbnormalProcessTerminationCount
TypeName                        : Microsoft.SharePoint.Administration.SPResourc
                                  eMeasure
DisplayName                     : AbnormalProcessTerminationCount
Id                              : 9056369d-768e-42bd-bd9c-67d810ad7936
Status                          : Online
Parent                          : SPUserCodeService Name=SPUserCodeV4
Version                         : 2410
Properties                      : {}
Farm                            : SPFarm Name=SharePoint_SP2010TestFarm_ConfigD
                                  B
UpgradedPersistedProperties     : {} </pre>
<p>In the above case the RecourcesPerPoint value is set to one. This means that whenever an Abnormal Process Termination occurs it will generate one &#8220;point&#8221;. You can also see that there is a AbsoluteLimit value. If any specific ResourceMeasure hits its AboluteLimit it will shut down the solution even if the daily quota of points is not reached. By typing the following you can see each ResourceMeasure&#8217;s ResourcesPerPoint and AbsoluteLimit values:</p>
<pre>PS &gt; $spCodeService.ResourceMeasures | select name, resourcesperpoint, absolutelimit</pre>
<pre>Name                                ResourcesPerPoint             AbsoluteLimit
----                                -----------------             -------------
AbnormalProcessTerminat...                          1                         2
CPUExecutionTime                                  200                        60
CriticalExceptionCount                             10                         3
IdlePercentProcessorTime                          100                        10
InvocationCount                                   100                       100
PercentProcessorTime                               85                       100
ProcessCPUCycles                         100000000000              100000000000
ProcessHandleCount                              10000                      5000
ProcessIOBytes                               10000000                 100000000
ProcessThreadCount                              10000                       200
ProcessVirtualBytes                        1000000000                4000000000
SharePointDatabaseQuery...                        400                       100
SharePointDatabaseQuery...                         20                        60
UnhandledExceptionCount                            50                         3
UnresponsiveprocessCount                            2                         1</pre>
<pre> </pre>
<p>It is possible to change the these values if you want to tweek how the points are calculated. To change the AbsoluteLimit on the AbnormalProcessTerminationCount you simply type: </p>
<pre>PS &gt; $spCodeService.ResourceMeasures["AbnormalProcessTerminationCount"] `
.AbsoluteLimit = 2</pre>
<p>If you want to change the Max Point quota for a specific site collection you can do that by typing: </p>
<pre>PS &gt; (get-spsite http://SPsiteURL).Quota.UserCodeMaximumLevel = 200</pre>
<p>Or of you want to change the quota on all site collections this is how you do. Get all site collections using the Get-SPSite cmdlet and then you pipe it to a foreach-object and then set the new value. </p>
<pre>PS &gt; Get-SPSite | foreach-object {$_.Quota.UserCodeMaximumLevel = 200}</pre>
]]></content:encoded>
			<wfw:commentRss>http://mysharepointofview.com/2010/10/quotas-and-locks-for-sandbox-solutions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How many sites are using a specific template?</title>
		<link>http://mysharepointofview.com/2010/09/how-many-sites-are-using-a-specific-template/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-many-sites-are-using-a-specific-template</link>
		<comments>http://mysharepointofview.com/2010/09/how-many-sites-are-using-a-specific-template/#comments</comments>
		<pubDate>Wed, 22 Sep 2010 17:31:35 +0000</pubDate>
		<dc:creator>Mattias Karlsson</dc:creator>
				<category><![CDATA[Script]]></category>
		<category><![CDATA[MOSS]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Template]]></category>
		<category><![CDATA[WSS]]></category>

		<guid isPermaLink="false">http://mysharepointofview.com/?p=871</guid>
		<description><![CDATA[I got a question the other day, if it was possible to in an easy way find out how many sites within a site collection were using the Blog template. There is a quite easy way using PowerShell to accomplish this and in this case we talk about SharePoint 2007/WSS 3.0 Open up PowerShell with [...]]]></description>
			<content:encoded><![CDATA[<p>I got a question the other day, if it was possible to in an easy way find out how many sites within a site collection were using the Blog template. There is a quite easy way using PowerShell to accomplish this and in this case we talk about SharePoint 2007/WSS 3.0</p>
<p>Open up PowerShell with an account that has access to the sites and type:</p>
<pre>[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$spsite = New-Object Microsoft.SharePoint.SPSite("http://yoursite")
($spsite.AllWebs | where {$_.WebTemplate -eq "BLOG#0"}).count</pre>
<p>I tested this on a quite small site collection ~500 webs. If it&#8217;s a large site collection (number of sites) you should be a bit careful since it might take up a lot of resources. If you use PowerShell V2 then you should first set the ThreadOption to ReuseThread like below.<br />
$host.Runspace.ThreadOptions = &#8220;ReuseThread&#8221;</p>
<p>If you want to search for another type of built-in or custom template you can do so by just changing the value &#8220;BLOG#0&#8243;. If you want to see all available templates and their internal name you type (where 1033 is your LCID):</p>
<pre>$spsite.GetWebTemplates(1033) | select Name</pre>
<p>That&#8217;s all for now!</p>
]]></content:encoded>
			<wfw:commentRss>http://mysharepointofview.com/2010/09/how-many-sites-are-using-a-specific-template/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>psconfig and secureresources</title>
		<link>http://mysharepointofview.com/2010/04/psconfig-and-secureresources/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=psconfig-and-secureresources</link>
		<comments>http://mysharepointofview.com/2010/04/psconfig-and-secureresources/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 15:53:17 +0000</pubDate>
		<dc:creator>Mattias Karlsson</dc:creator>
				<category><![CDATA[Script]]></category>
		<category><![CDATA[MOSS]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[PSCONFIG]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[The book]]></category>

		<guid isPermaLink="false">http://mysharepointofview.com/?p=831</guid>
		<description><![CDATA[I&#8217;m currently writing a chapter (PowerShell for Microsoft SharePoint 2010 Administrators) about scripted installations in SharePoint 2010 using PowerShell. In 2010 there are a couple of cmdlets that does more or less the same thing as you do with psconfig when scripting installations today. One of the cmdlets that needs to be used when scripting [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently writing a chapter (<a href="http://sharepointandpowershell.com" target="_self">PowerShell for Microsoft SharePoint 2010 Administrators</a>) about scripted installations in SharePoint 2010 using PowerShell. In 2010 there are a couple of cmdlets that does more or less the same thing as you do with psconfig when scripting installations today.</p>
<p>One of the cmdlets that needs to be used when scripting a 2010 farm using PowerShell is the <em>Initialize-SPResourceSecurity </em>This does the same as psconfig -cmd secureresources. A have used this hundreds of times and knows that it is, according to the <a href="http://technet.microsoft.com/en-us/library/cc263093.aspx" target="_blank">technet command line reference</a>  &#8221;Performs SharePoint Products and Technologies resource security enforcement on the server. For example, security is enforced on files, folders, and registry keys&#8221;. Earlier I have been happy with that explanation since it&#8217;s quite obvious what it does right? But what does this really mean, what security is set and on what folders and files? It turns out that if you Google on it, everyone mentioning it says more or less the same as the sentence mentioned on Technet. This made me even more curios, and to find out you can actually run the command from the command line and get the result there or you can pipe it out to a txt file like this:</p>
<p><em>psconfig -cmd secureresources &gt; c:tempsecureresources.txt</em></p>
<p>The below is a copy of the result (Moss) and should give you a hint on what it actually does and what files, foldres and registry keys are affected.</p>
<p>Successfully secured resource &#8216;HKEY_LOCAL_MACHINESoftwareMicrosoftOffice Server12.0LoadBalancerSettings&#8217; of type &#8216;RegKey&#8217; by granting security group &#8216;LocalService&#8217; &#8216;Read&#8217; permissions .</p>
<p>Successfully secured resource &#8216;E:Microsoft Office servers12.0WebServicesRoot&#8217; of type &#8216;Directory&#8217; by granting security group &#8216;Users&#8217; &#8216;Read, Execute&#8217; permissions .</p>
<p>Successfully secured resource &#8216;HKEY_LOCAL_MACHINESoftwareMicrosoftOffice Server12.0LoadBalancerSettings&#8217; of type &#8216;RegKey&#8217; by granting security group &#8216;WSS_WPG&#8217; &#8216;Read, Write&#8217; permissions .</p>
<p>Successfully secured resource &#8216;HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesVSS&#8217; of type &#8216;RegKey&#8217; by granting security group &#8216;WSS_ADMIN_WPG&#8217; &#8216;Full Control&#8217; permissions .</p>
<p>Successfully secured resource &#8216;HKEY_LOCAL_MACHINESoftwareMicrosoftOffice Server12.0LauncherSettings&#8217; of type &#8216;RegKey&#8217; by granting security group &#8216;LocalSystem&#8217; &#8216;Read&#8217; permissions .</p>
<p>Successfully secured resource &#8216;E:Microsoft Office servers12.0&#8242; of type &#8216;Directory&#8217; by granting security group &#8216;WSS_WPG&#8217; &#8216;Read, Execute&#8217; permissions .</p>
<p>Successfully secured resource &#8216;E:Microsoft Office servers12.0WebServicesRoot&#8217; of type &#8216;Directory&#8217; by granting security group &#8216;NetworkService&#8217; &#8216;Read, Execute&#8217; permissions .</p>
<p>Successfully secured resource &#8216;HKEY_LOCAL_MACHINESoftwareMicrosoftShared ToolsWeb Server Extensions12.0WSSDiagnostics&#8217; of type &#8216;RegKey&#8217; by granting security group &#8216;WSS_WPG&#8217; &#8216;Read, Write&#8217; permissions .</p>
<p>Successfully secured resource &#8216;E:Microsoft Office Servers12.0Data&#8217; of type &#8216;Directory&#8217; by granting security group &#8216;WSS_ADMIN_WPG&#8217; &#8216;Full Control&#8217; permissions .</p>
<p>Successfully secured resource &#8216;HKEY_LOCAL_MACHINESoftwareMicrosoftOffice Server12.0Diagnostics&#8217; of type &#8216;RegKey&#8217; by granting security group &#8216;WSS_WPG&#8217; &#8216;Read, Write&#8217; permissions .</p>
<p>Successfully secured resource &#8216;E:Microsoft Office servers12.0&#8242; of type &#8216;Directory&#8217; by granting security group &#8216;Users&#8217; &#8216;Read, Execute&#8217; permissions .</p>
<p>Successfully secured resource &#8216;E:Microsoft Office servers12.0WebServices&#8217; of type &#8216;Directory&#8217; by granting security group &#8216;WSS_WPG&#8217; &#8216;Read&#8217; permissions .</p>
<p>Successfully secured resource &#8216;HKEY_CLASSES_ROOTAPPID{6002D29F-1366-4523-88C1-56D59BFEF8CB}&#8217; of type &#8216;RegKey&#8217; by granting security group &#8216;WSS_ADMIN_WPG&#8217; &#8216;Full Control&#8217; permissions .</p>
<p>Successfully secured resource &#8216;E:Microsoft Office servers12.0Logs&#8217; of type &#8216;Directory&#8217; by granting security group &#8216;WSS_ADMIN_WPG&#8217; &#8216;Full Control&#8217; permissions .</p>
<p>Successfully secured resource &#8216;HKEY_LOCAL_MACHINESoftwareMicrosoftShared ToolsWeb Server Extensions12.0Search&#8217; of type &#8216;RegKey&#8217; by granting security group &#8216;WSS_ADMIN_WPG&#8217; &#8216;Full Control&#8217; permissions .</p>
<p>Successfully secured resource &#8216;C:WINDOWSSystem32driversetcHOSTS&#8217; of type &#8216;File&#8217; by granting security group &#8216;WSS_ADMIN_WPG&#8217; &#8216;Read, Write&#8217; permissions .</p>
<p>Successfully secured resource &#8216;E:Microsoft Office servers12.0Bin&#8217; of type &#8216;Directory&#8217; by granting security group &#8216;LocalService&#8217; &#8216;Read, Execute&#8217; permissions .</p>
<p>Successfully secured resource &#8216;HKEY_LOCAL_MACHINESoftwareMicrosoftOffice Server12.0LauncherSettings&#8217; of type &#8216;RegKey&#8217; by granting security group &#8216;WSS_ADMIN_WPG&#8217; &#8216;Read, Write&#8217; permissions .</p>
<p>Successfully secured resource &#8216;E:Microsoft Office servers12.0Logs&#8217; of type &#8216;Directory&#8217; by granting security group &#8216;Users&#8217; &#8216;Read, Execute, Write&#8217; permissions .</p>
<p>Successfully secured resource &#8216;E:Microsoft Office servers12.0Logs&#8217; of type &#8216;Directory&#8217; by granting security group &#8216;WSS_WPG&#8217; &#8216;Read, Write&#8217; permissions .</p>
<p>Successfully secured resource &#8216;HKEY_LOCAL_MACHINESoftwareMicrosoftShared ToolsWeb Server Extensions12.0WSSComponentsToRegister&#8217; of type &#8216;RegKey&#8217; by granting security group &#8216;WSS_ADMIN_WPG&#8217; &#8216;Read, Write&#8217; permissions .</p>
<p>Successfully secured resource &#8216;E:Microsoft Office Servers12.0DataOffice Server&#8217; of type &#8216;Directory&#8217; by granting security group &#8216;WSS_ADMIN_WPG&#8217; &#8216;Full Control&#8217; permissions .</p>
<p>Successfully secured resource &#8216;HKEY_LOCAL_MACHINESoftwareMicrosoftOffice Server12.0Search&#8217; of type &#8216;RegKey&#8217; by granting security group &#8216;WSS_ADMIN_WPG&#8217; &#8216;Full Control&#8217; permissions .</p>
<p>Successfully secured resource &#8216;HKEY_CLASSES_ROOTAPPID{58F1D482-A132-4297-9B8A-F8E4E600CDF6}&#8217; of type &#8216;RegKey&#8217; by granting security group &#8216;WSS_ADMIN_WPG&#8217; &#8216;Full Control&#8217; permissions .</p>
<p>Successfully secured resource &#8216;E:Microsoft Office servers12.0Bin&#8217; of type &#8216;Directory&#8217; by granting security group &#8216;Users&#8217; &#8216;Read, Execute&#8217; permissions .</p>
<p>Successfully secured resource &#8216;HKEY_LOCAL_MACHINESoftwareMicrosoftOffice Server12.0SearchSetup&#8217; of type &#8216;RegKey&#8217; by granting security group &#8216;NetworkService&#8217; &#8216;Read&#8217; permissions .</p>
<p>Successfully secured resource &#8216;C:WINDOWSTasks&#8217; of type &#8216;Directory&#8217; by granting security group &#8216;WSS_ADMIN_WPG&#8217; &#8216;Full Control&#8217; permissions .</p>
<p>Successfully secured resource &#8216;HKEY_LOCAL_MACHINESoftwareMicrosoftOffice Server12.0LoadBalancerSettings&#8217; of type &#8216;RegKey&#8217; by granting security group &#8216;WSS_ADMIN_WPG&#8217; &#8216;Read, Write&#8217; permissions .</p>
<p>Successfully secured resource &#8216;HKEY_LOCAL_MACHINESoftwareMicrosoftShared ToolsWeb Server Extensions12.0Search&#8217; of type &#8216;RegKey&#8217; by granting security group &#8216;WSS_WPG&#8217; &#8216;Read&#8217; permissions .</p>
<p>Successfully secured resource &#8216;HKEY_LOCAL_MACHINESOFTWAREMicrosoftOffice Server12.0&#8242; of type &#8216;RegKey&#8217; by granting security group &#8216;WSS_WPG&#8217; &#8216;Read&#8217; permissions .</p>
<p>Successfully secured resource &#8216;HKEY_LOCAL_MACHINESOFTWAREMicrosoftOffice Server12.0&#8242; of type &#8216;RegKey&#8217; by granting security group &#8216;WSS_ADMIN_WPG&#8217; &#8216;Full Control&#8217; permissions .</p>
<p>Successfully secured resource &#8216;E:Microsoft Office servers12.0WebServices&#8217; of type &#8216;Directory&#8217; by granting security group &#8216;WSS_ADMIN_WPG&#8217; &#8216;Read, Write&#8217; permissions .</p>
<p>Successfully secured resource &#8216;E:Microsoft Office servers12.0&#8242; of type &#8216;Directory&#8217; by granting security group &#8216;WSS_ADMIN_WPG&#8217; &#8216;Full Control&#8217; permissions .</p>
<p>Successfully secured resource &#8216;HKEY_LOCAL_MACHINESoftwareMicrosoftOffice12.0Registration{90120000-110D-0000-1000-0000000FF1CE}&#8217; of type &#8216;RegKey&#8217; by granting security group &#8216;WSS_ADMIN_WPG&#8217; &#8216;Read, Write&#8217; permissions .</p>
<p>Successfully secured resource &#8216;HKEY_LOCAL_MACHINESoftwareMicrosoftOffice Server12.0LauncherSettings&#8217; of type &#8216;RegKey&#8217; by granting security group &#8216;WSS_WPG&#8217; &#8216;Read, Write&#8217; permissions .</p>
<p>Successfully secured resource &#8216;HKEY_LOCAL_MACHINESOFTWAREMicrosoftOffice Server&#8217; of type &#8216;RegKey&#8217; by granting security group &#8216;WSS_ADMIN_WPG&#8217; &#8216;Read&#8217; permissions .</p>
<p>Thanks for the tip Andrija!</p>
]]></content:encoded>
			<wfw:commentRss>http://mysharepointofview.com/2010/04/psconfig-and-secureresources/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Update of SP-Upgrade script</title>
		<link>http://mysharepointofview.com/2010/04/update-of-sp-upgrade-script/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=update-of-sp-upgrade-script</link>
		<comments>http://mysharepointofview.com/2010/04/update-of-sp-upgrade-script/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 09:42:08 +0000</pubDate>
		<dc:creator>Mattias Karlsson</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Cumulative update]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[sp-upgrade]]></category>
		<category><![CDATA[Upgrade]]></category>

		<guid isPermaLink="false">http://mysharepointofview.com/?p=828</guid>
		<description><![CDATA[After some feedback I have updated the SP-Upgrade script created 2 weeks ago. First there was a bug in the script related to the export of Web Application names and then I added switch that makes i possible to only export the content database information to an XML File. This is how the help looks [...]]]></description>
			<content:encoded><![CDATA[<p>After some feedback I have updated the SP-Upgrade script created 2 weeks ago. First there was a bug in the script related to the export of Web Application names and then I added switch that makes i possible to only export the content database information to an XML File. This is how the help looks now and you find more information about the script here: <a href="http://mysharepointofview.com/2010/03/automate-sharepoint-patching-with-powershell/">http://mysharepointofview.com/2010/03/automate-sharepoint-patching-with-powershell/</a></p>
<p>SYNTAX:<br />
SP-Upgrade -help<br />
Displays the help topic for the script</p>
<p>SP-Upgrade -Binaries<br />
Installs the wss and MOSS Binaries on the local machine</p>
<p>SP-Upgrade -Binaries -DetacheContentDBs<br />
Detaches all content databases and installs the wss and MOSS Binaries on the local machine</p>
<p>SP-Upgrade -PSConfig<br />
Runs the SharePoint Product and Configuration Wizard</p>
<p>SP-Upgrade -PSConfig -AttachContentDBs<br />
Runs the SharePoint Product and Configuration Wizard and attaches all content databases</p>
<p>SP-Upgrade -OnlyAttach<br />
Attaches all Content databases found in ContentDatabases.xml</p>
<p>SP-Upgrade -OnlyExport<br />
Exports all Content databases found to ContentDatabases.xml</p>
]]></content:encoded>
			<wfw:commentRss>http://mysharepointofview.com/2010/04/update-of-sp-upgrade-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automate SharePoint patching with PowerShell</title>
		<link>http://mysharepointofview.com/2010/03/automate-sharepoint-patching-with-powershell/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=automate-sharepoint-patching-with-powershell</link>
		<comments>http://mysharepointofview.com/2010/03/automate-sharepoint-patching-with-powershell/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 16:55:54 +0000</pubDate>
		<dc:creator>Mattias Karlsson</dc:creator>
				<category><![CDATA[Script]]></category>
		<category><![CDATA[Cumulative update]]></category>
		<category><![CDATA[Patching]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[PSCONFIG]]></category>

		<guid isPermaLink="false">http://mysharepointofview.com/?p=799</guid>
		<description><![CDATA[My last addition to the community is a script that can help you with the patching of SharePoint environments. The script was from the beginning made for Cumulative Updates but can be used in other scenarios as well. As in all CU installations it&#8217;s done in two steps; install Binaries and then run the SharePoint [...]]]></description>
			<content:encoded><![CDATA[<p>My last addition to the community is a script that can help you with the patching of SharePoint environments. The script was from the beginning made for Cumulative Updates but can be used in other scenarios as well. As in all CU installations it&#8217;s done in two steps; install Binaries and then run the SharePoint Configuration Wizard/PSConfig. What I wanted the script to do was they key things.</p>
<ol>
<li>Log the amount of time it takes to install the updates to estimate downtime in produciton environment</li>
<li>Be able to reuse it without having to change any code</li>
<li>Be able to choose if I wanted to detach all content databases before the binaries and then attach it after psconfig and then have that automated.</li>
</ol>
<p>The first two things are actually not that tricky but the last point needed some more efforts.</p>
<ol>
<li>This is how you work with the script:<br />
Download it from [Download not found] of from the <a href="http://mysharepointofview.com/downloads">download</a> section, and put it on the SharePoint server/servers that are about to be upgraded.</li>
<li>Create a folder on the same level as the SP-Upgrade.ps1 file and name it Media.</li>
<li>Download and extract the CU or the patches that should be installed and put it in the Media folder.</li>
<li>Rename the .exe files in the Media folder so that they have a digit in the beginning representing in what order they should be installed.<br />
For instance, if you want to upgrade your MOSS environment you have both the WSS and MOSS CU name the WSS CU 01[WSSFilename].exe and 02[MossFileName].exe</li>
<li>Open up a PowerShell command window with enough priviliges to run the setup.</li>
<li>Depending on your environment and what approach you want to use, run SP-Upgrade with any of the following switches.</li>
</ol>
<table>
<tbody>
<tr>
<td><strong>Switches</strong></td>
<td> </td>
</tr>
<tr>
<td>-Binaries</td>
<td>Installs the binaries located in the Media folder</td>
</tr>
<tr>
<td>-PSConfig</td>
<td>Runs the SharePoint Product and Configuration Wizard using: <br />
psconfig -cmd upgrade -inplace b2b -wait -force <em>(complete command-line reference found here: </em><a href="http://technet.microsoft.com/en-us/library/cc263093.aspx"><em>http://technet.microsoft.com/en-us/library/cc263093.aspx</em></a><em>)</em></td>
</tr>
<tr>
<td>-DetachContentDBs</td>
<td>Used together with -Binaries. Detaches content databases before installing the media and stores them in a xml file named ContentDatabases.xml located in the same folder as your SP-Upgrade.ps1 file</td>
</tr>
<tr>
<td>-AttachContentDBs</td>
<td>Used together with -PSConfig. Attach content databases after PSConfig. Note that if you have several SharePoint Server this should be used on the last server when -PSConfig is run on all other servers.</td>
</tr>
<tr>
<td>-OnlyAttach</td>
<td>Will only attach databases using ContentDatabases.xml. Used if you have run PSConfig on all servers and then just want to attach it.</td>
</tr>
<tr>
<td>-OnlyExport</td>
<td>Will only export databases to ContentDatabases.xml.</td>
</tr>
<tr>
<td>-help</td>
<td>Displays the help topic</td>
</tr>
</tbody>
</table>
<p>When the script is run it will create a Log folder and put all logs in that folder. Except for the log files generated by the installation I create a log file named Upgradelog.log and will contain the steps taken by the script together with time stamps. The time stamps are also printed to the screen and can display installation times, detach and attach times of content db&#8217;s.</p>
<p>When detaching the content databases the following information is stored in the ContentDatabases.xml file:</p>
<p>Web Application URL<br />
Content Database Name<br />
Content Database Max Site Count<br />
Content Database Site Warning Level<br />
Content Database Read Only<br />
Content Database Status<br />
Content Database Server Name<br />
Detached Time<br />
Reattached Time <em>(Used when attached)</em></p>
<p><strong>Syntax examples</strong></p>
<p>SP-Upgrade -help<br />
Displays the help topic for the script</p>
<p>SP-Upgrade -Binaries<br />
Installs the wss and MOSS Binaries on the local machine</p>
<p>SP-Upgrade -Binaries -DetacheContentDBs<br />
Detaches all content databases and installs the wss and MOSS Binaries on the local machine</p>
<p>SP-Upgrade -PSConfig<br />
Runs the SharePoint Product and Configuration Wizard</p>
<p>SP-Upgrade -PSConfig -AttachContentDBs<br />
Runs the SharePoint Product and Configuration Wizard and attaches all content databases</p>
<p>SP-Upgrade -OnlyAttach<br />
Attaches all Content databases found in ContentDatabases.xml</p>
<p>Feedback and ideas for improvement is more then welcome!</p>
]]></content:encoded>
			<wfw:commentRss>http://mysharepointofview.com/2010/03/automate-sharepoint-patching-with-powershell/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Cancel multiple SharePoint Workflows using PowerShell</title>
		<link>http://mysharepointofview.com/2010/02/cancel-multiple-sharepoint-workflows-using-powershell/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=cancel-multiple-sharepoint-workflows-using-powershell</link>
		<comments>http://mysharepointofview.com/2010/02/cancel-multiple-sharepoint-workflows-using-powershell/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 12:49:45 +0000</pubDate>
		<dc:creator>Mattias Karlsson</dc:creator>
				<category><![CDATA[Script]]></category>
		<category><![CDATA[MOSS]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Workflow]]></category>
		<category><![CDATA[WSS]]></category>

		<guid isPermaLink="false">http://mysharepointofview.com/?p=764</guid>
		<description><![CDATA[Have you ever been in a situation where you have had a lot of workflows that has been started and ended up in a Error Occurred state? Where you tired of terminating them one by one before you could start the workflow again? Well I was, so I wrote a small and simple PowerShellScript for it. What [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever been in a situation where you have had a lot of workflows that has been started and ended up in a Error Occurred state? Where you tired of terminating them one by one before you could start the workflow again? Well I was, so I wrote a small and simple PowerShellScript for it.</p>
<p>What the script does is that you specify a site, list and workflow name and then all workflows will be terminated so that you can run them again. I also included the option to include already running Workflows and also a Restart parameter that could actually be used to start multiple Workflows only.</p>
<p><strong>This is how it looks:</strong></p>
<p><em>DESCRIPTION:<br />
NAME: Cancel-SPWorkflow<br />
Cancel SharePoint Workflows and restart them if wanted</em></p>
<table border="0" cellspacing="1" cellpadding="0" width="450">
<tbody>
<tr>
<td><em>PARAMETERS:</em></td>
<td><em> </em></td>
</tr>
<tr>
<td><em>-Site</em></td>
<td><em>Url to the SharePoint Site</em></td>
</tr>
<tr>
<td><em>-List</em></td>
<td><em>Name of the list</em></td>
</tr>
<tr>
<td><em>-Workflowname</em></td>
<td><em>Name of the workflow</em></td>
</tr>
<tr>
<td><em>-Restart</em></td>
<td><em>Optional if you want to restart the workflows</em></td>
</tr>
<tr>
<td><em>-IncludeRunning</em></td>
<td><em>Optional if you want to include running workflows</em></td>
</tr>
<tr>
<td><em>-help</em></td>
<td><em>Displays the help topic</em></td>
</tr>
</tbody>
</table>
<p><em>SYNTAX:<br />
Cancel-SPWorkflow -help<br />
Displays the help topic for the script</em></p>
<p><em>Cancel-SPWorkflow -site </em><em>http://yourSPSite</em> <em>-list Listname -Workflowname YourWorkflow<br />
Terminates all workflows with the specific workflow name</em></p>
<p><em>Cancel-SPWorkflow -site </em><em>http://yourSPSite</em> <em>-list Listname -Workflowname YourWorkflow -Includerunning<br />
Terminates all workflows with the specific workflow name and include running workflows</em></p>
<p><em>Cancel-SPWorkflow -site </em><em>http://yourSPSite</em> <em>-list Listname -Workflowname YourWorkflow -restart<br />
Terminates all workflows with the specific workflow name and then restart the workflow for all items</em></p>
<p>The key in the script is how we cancel the workflow. That is done through the SPWorkflowManager and done like.</p>
<p><em>[Microsoft.SharePoint.Workflow.SPWorkflowManager]::CancelWorkflow($Workflow)</em></p>
<p>And when we want to start a workflow we first need the workflow association and association data together with the SharePoint item to start it for.</p>
<p><em>$SPList.Parentweb.site.workflowmanager.startworkflow($item, $WFAssociation, $WFAssociation.AssociationData)</em></p>
<p>You find the whole script [Download not found] or from the <a href="http://mysharepointofview.com/downloads">Downloads</a> section</p>
<p>Hope you find it useful</p>
]]></content:encoded>
			<wfw:commentRss>http://mysharepointofview.com/2010/02/cancel-multiple-sharepoint-workflows-using-powershell/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Copy list items to folder using PowerShell</title>
		<link>http://mysharepointofview.com/2010/01/copy-list-items-to-folder-using-powershell/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=copy-list-items-to-folder-using-powershell</link>
		<comments>http://mysharepointofview.com/2010/01/copy-list-items-to-folder-using-powershell/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 15:32:46 +0000</pubDate>
		<dc:creator>Mattias Karlsson</dc:creator>
				<category><![CDATA[Script]]></category>
		<category><![CDATA[MOSS]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[WSS]]></category>

		<guid isPermaLink="false">http://mysharepointofview.com/?p=743</guid>
		<description><![CDATA[Here comes a quick PowerShell tip at the end of the week. Earlier I have posted a script (found at the download section) that helps copy SharePoint List Items from one list to another, read more about it here. But today I wanted to use the script to copy items to a specific folder in [...]]]></description>
			<content:encoded><![CDATA[<p>Here comes a quick PowerShell tip at the end of the week. Earlier I have posted a script (found at the <a href="http://mysharepointofview.com/downloads">download section</a>) that helps copy SharePoint List Items from one list to another, read more about it <a href="http://mysharepointofview.com/2009/09/copy-items-from-one-list-to-another-using-powershell/">here</a>.</p>
<p>But today I wanted to use the script to copy items to a specific folder in that list and it was a bit tricky at the first to understand how this could be done. But after some testing I figured it out and this is how you do.</p>
<p># First open the list to create the new item in.<br />
<em>$TargetWeb = New-Object Microsoft.SharePoint.SPSite(</em><em>http://yoursite</em><em>)<br />
$OpenTargetWeb = $TargetWeb.OpenWeb()<br />
$OpenTargetList = $OpenTargetWeb.Lists[$TargetList]</em></p>
<p># Then we need to get the folder name and set the objecttype<br />
<em>$FSObjectytype = [microsoft.sharepoint.SPFilesystemobjecttype]::File<br />
$Folder = $targetweb.GetFolder(</em><a href="http://urlToFolder"><em>http://urlToFolder</em></a><em>)</em></p>
<p># Now we can create the new Item<br />
<em>$NewItem = $OpenTargetList.items.Add($Folder.Folder.ServerRelativeUrl, $FSObjectytype, $null)</em></p>
<p># Add values<br />
<em>$NewItem["Title"] = &#8220;Yada Yada&#8221;</em></p>
<p># Finally use update to create the new item<br />
<em>$NewItem.update()</em></p>
<p>My intention is to add this to my <a href="http://mysharepointofview.com/downloads">copy items</a> script later on.</p>
]]></content:encoded>
			<wfw:commentRss>http://mysharepointofview.com/2010/01/copy-list-items-to-folder-using-powershell/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Enumerate all content databases using PowerShell</title>
		<link>http://mysharepointofview.com/2010/01/enumerate-all-content-databases-using-powershell/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=enumerate-all-content-databases-using-powershell</link>
		<comments>http://mysharepointofview.com/2010/01/enumerate-all-content-databases-using-powershell/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 20:38:25 +0000</pubDate>
		<dc:creator>Mattias Karlsson</dc:creator>
				<category><![CDATA[Script]]></category>
		<category><![CDATA[Content database]]></category>
		<category><![CDATA[Enumerate]]></category>
		<category><![CDATA[MOSS]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[WSS]]></category>

		<guid isPermaLink="false">http://mysharepointofview.com/?p=723</guid>
		<description><![CDATA[[2010-09-30 Updated with new featuers and download location] It&#8217;s time for another PowerShell script. This one I wrote in a project where I needed to know what content databases was used by each farm. We had a large SQL cluster and more then one farm was using it. Since there is no enum content databases [...]]]></description>
			<content:encoded><![CDATA[<p><span style="color: #ff0000;">[2010-09-30 Updated with new featuers and download location]<br />
</span><br />
It&#8217;s time for another PowerShell script. This one I wrote in a project where I needed to know what content databases was used by each farm. We had a large SQL cluster and more then one farm was using it. Since there is no enum content databases in stsadm i made this simple PowerShell script.</p>
<p>What it does basically is that it connects to the SPWebService and for each web application it find it lists all SharePoint Content Databases and writes it to either a xml or csv file named ContentDatabases in the folder where you run the script.</p>
<p>This is how you use it:</p>
<pre>.SP-EnumContentDBs -OutPutFormat xml | csv</pre>
<p>And now in the first version you will get the following information:<br />
Web Application name<br />
Content Database Name<br />
Content Database ID(GUID)<br />
Current amount of sites in DB<br />
Maximum site count allowed in DB<br />
<span style="color: #ff0000;">Warning site level</span><br />
Read only state<br />
<span style="color: #ff0000;">Database Server</span></p>
<p>But it&#8217;s easy to add more attributes by just adding more properties to the code. You can find all available properties at msdn: <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spcontentdatabase_properties">http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spcontentdatabase_properties.</a></p>
<p>If you want to make a comparison to what you have on the SQL server you can easily run the script, import it to e.g. Excel and then run the following on the SQL server to get the list of databases:</p>
<p><em>select name from master..sysdatabases where dbid&gt;4 order by name</em></p>
<p>I have started to move some of my PowerShell scripts to the codeplex project <a href="http://sharepointpsscripts.codeplex.com/" target="_blank">SharePoint Management PowerShell scripts </a>This way I hope more people will find it usefull and others can participate in improving them. This script can be found here: <a href="http://sharepointpsscripts.codeplex.com/releases/view/53114">http://sharepointpsscripts.codeplex.com/releases/view/53114</a></p>
<p><span style="text-decoration: line-through;">You can download the script by clicking here or it&#8217;s available at the </span><a href="http://mysharepointofview.com/downloads"><span style="text-decoration: line-through;">download</span></a><span style="text-decoration: line-through;"> section.</span></p>
<p>Finally thanks to Travis Lingenfelder who with his blog post helped me with some strugeling getting the names out since it differs some from c#.</p>
<p><a href="http://blogs.catapultsystems.com/tlingenfelder/archive/2009/06/26/using-non-cls-compliant-types-in-powershell.aspx">http://blogs.catapultsystems.com/tlingenfelder/archive/2009/06/26/using-non-cls-compliant-types-in-powershell.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://mysharepointofview.com/2010/01/enumerate-all-content-databases-using-powershell/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

