Skip to main content

From The Field

Go Search
From The Field
  

From The Field > Categories
Parse IIS Logs to Report on Page Performance
Once again - this is not strictly SharePoint but rather general IIS, however it may prove very handy for you SharePoint guys out there. This script has helped a customer of mine to identify some serious (and evasive!) application bottlenecks - so check it out in the Technet Script Center Gallery
Single Server Complete Install of SharePoint 2010 using local accounts
 
UPDATED 19 Nov 2009 - It is suggested the reader refer to MSDN article -
Setting Up the Development Environment for SharePoint Server
 - http://msdn.microsoft.com/en-us/library/ee554869(office.14).aspx
 
Before commencing with implementing this approach to a single server installation.
 
Something that was possible in SharePoint Server 2007 has become tricky in SharePoint Server 2010. The complete installation on a single server using non-domain accounts. Something most developers, demonstrators and testers do a lot of suddenly requires the use of domain accounts instead of local machine accounts. Or does it....
 
The recommendation for a single server build of SharePoint 2010 is to use the Stand Alone installation giving you SQL express and a default configuration. But what if you want to use SQL Server 2008 and to have more control over the build, and to use local service accounts. In this case you need to use complete install and either PowerShell alone or a combination of Windows PowerShell and PSCONFIG(UI).EXE
 
To begin with carry out your SharePoint 2010 installation using the advanced option and complete as the server type. This is recommended in a farm configuration.
 
Next you would think to use either PSCONFIG or PSCONFIGUI to create the farm. Well you would be wrong
 
PSCONFIG.EXE -cmd configdb -create -server neilhw2k8r2 -database sharepoint_2010_config -user neilhw2k8r2\administrator -password ******** -passphrase ********
-admincontentdatabase sharepoint2010_admincontent
 
Results in
 
SharePoint Products Configuration Wizard version 14.0.4514.1009. Copyright (C) Microsoft Corporation 2010. All rights reserved.
The specified user neilhw2k8r2\administrator is a local account.
Local accounts should only be used in stand alone mode.
 
So how do we get around this limitation without using the corporate domain or else promoting the server to a domain controller.
 
Windows PowerShell is your friend, New-SPConfigurationDatabase allows you to specify none domain credentials for the farm.
 
To execute this command launch the SharePoint 2010 management shell (in the same location as the central admin link) and simply type the command at the cursor and press enter.
 
CreateNewFarm
 
The beauty of the Windows PowerShell approach is you get prompted for the missing command line attributes instead of the rather horrible error dialog that PSConfig throws at you
 
After this completes you will find in SQL a new configuration database and an admin content database (unfortunately the GUID is back but that can be fixed if necessary)
 
Next the simplest way to complete the installation is revery back to PSConfigUI as you now are starting with the server already joined to the farm.
 
 
 
Follow the wizard through the same options as you had with SharePoint 2007 and complete the installation/configuration with the following screen
 
 
Clicking Fiinish launches the central admin website and after agreeing to report back customer experiences to Microsoft (or not) you get your first look at SharePoint 2010 central admin and the configuration wizards.
 
 
So wizard - or - manual configuration. That's a subject for another post so come back for more...
 
 
 
 
Estimating Content Database Transaction Log Growth Rate - With PowerShell V2

You might argue once you’re finished reading this post that it belongs more in a SQL-focused blog rather than a SharePoint one; however it was SharePoint that brought it about, so I thought there might be other SharePoint administrators out there who will find it useful…

 

It all began when a customer of mine asked me for advice on measuring the rate of growth of the transaction logs of their content databases – which I found rather difficult to provide off the top of my head. Really, it is only easy and obvious if a transaction log file is configured for autogrowth and the log is never truncated, in which case you can just monitor the size of the .ldf file – but honestly, if your databases are configured this way, measurement should (and will!) be the last thing on your mind! And in any case, the customer in question had pre-sized transaction log files, with logs truncated hourly.

 

After some musing, we arrived at a solution involving use of the relevant SQL performance counter and a PowerShell script to parse it – thanks to the rather useful Import-Counter cmdlet available in PowerShell V2. So, here’s what we had to do:

 

1)      On the target SQL server, set up a performance log with an instance of the 'Log File(s) Used Size (KB)' counter for each database we were interested in.

2)      Run the log for an hour (could be any period of time), then copy it over to a machine running Windows 7 – only because we had one, alternatively could use any machine with the CTP of PowerShell V2 installed.

3)      Run the following script, specifying the log file as the value for the input parameter:

 

param ([uri]$logfile = $(throw "Path to logfile not specified!"))

 

# Use the Import-Counter cmdlet to import perf log data into an array of data samples

# and store it in a variable

$logdata = Import-Counter $logfile.LocalPath;

 

# Iinitialize an empty array that will hold an object for each dynamically discovered instance

$counters = @();

 

# Analyze the first data sample to discover counter instances

$logdata[0].CounterSamples |

 Foreach-Object `

 {

  if ($_.Path -ilike '*log file(s) used size (kb)')

  {

  # Store the discovered instance as a hastable and add it to the $counters array

    $counters += @{path=$_.Path; instance = $_.InstanceName};

  }

 }

 

# Process all counter instances, one at a time

$counters |

 Foreach-Object `

 {

  $counter = $_;

  # Analyze each data sample

  $logdata |

   Foreach-Object `

   {

    # Filter down counter samples by matching with the name and path of the

    # currently processed counter instance

    $_.CounterSamples |

     Where-Object {($_.Path -eq $counter.path) -and ($_.InstanceName -eq $counter.instance)}

   } |

   Foreach-Object `

   { # This is the Begin-Processing clause, only executed once

     # Ensure the necessary variables are nullified before each sample is processed

    $first = $null;

    $prev = $null;

    $total = $null

   } `

   { # This is the Process-Object, executed for each data sample

     # The following algorithm identifies the first and the last value in

     # each consecutive period during which the size was on the increase

     # (e.g. from immediately after a truncation to the next truncation)

     # and sums up the differences between all such pairs of values

     if (-not $first)

      {

       $first = $_.CookedValue;

      }

      if (-not $prev)

       {

        $prev = $_.CookedValue;

       }

      if ($_.CookedValue -lt $prev)

       {

        $total += ($prev - $first);

        $first = $_.CookedValue;

       }

      $prev = $_.CookedValue;

     } `

     {

      if ($prev -gt $first)

       {

        $total += ($prev - $first);

       }

      # Round the final result for the current counter instance

      # and store it in the same hashtable

      $counter.total = [math]::Round(($total / 1KB),2)

     }

    }

 

Write-Host

Write-Host ("Log start:`t`t`t{0}" -f $logdata[0].TimeStamp);

Write-Host ("Log end:`t`t`t{0}" -f $logdata[-1].TimeStamp);

# Calculate the duration of the logging period

$duration = ($logdata[-1].TimeStamp - $logdata[0].TimeStamp);

Write-Host ("Total duration (hh:mm:ss):`t{0:d2}:{1:d2}:{2:d2}" -f $duration.Hours, $duration.Minutes, $duration.Seconds);

Write-Host ("Number of data samples:`t`t{0}" -f $logdata.Length)

Write-Host ("Sampling interval (sec):`t{0}" -f ($logdata[-1].TimeStamp - $logdata[-2].TimeStamp).Seconds)

 

$counters |

      select @{n="Database Name";e={$_.instance}}, @{n="Log File Growth (Mb)"; e={$_.total}} |

            Sort-Object "Log File Growth (Mb)" -descending |

                  Format-Table –autosize

 

What we see in the result is this nice report, with the most heavily utilized database appearing on top:

 

PowerShell Window

Create Managed Properties - The Easy Way
OK, so I got to publish another script to the SharePoint Management PowerShell scripts project - this one is called Set-ManagedProperty. Does exactly what the name suggests - allows you to automate creation of managed properties in Search configuration and mapping them onto crawled properties.
 
You may find this especially useful if you are planning to install Podcasting Kit for SharePoint (or have to re-build it regularly). One of the most tedious steps in the installation and configuration of PKS has always been having to create over a dozen of managed properties - now all you have to do is download and run this script, as it even defaults to properties required by PKS if given no other input!
PowerShell Has Arrived!
This blog is long due a PowerShell section, so finally I'm starting one with this post!
 
I've been meaning for quite a long time to share my experiences in this area in the form of ready-to-use scripts here, but after some consideration I've decided to join the SharePoint Management PowerShell scripts project on CodePlex. So, this week I was given access and uploaded the following:
 
Apply-SPQuotaTemplate.ps1
Get-SPSites.ps1
Get-SiteGroups.ps1
Edit-SPGroup.ps1
 
Quite a few more are to be posted in the weeks to come, subject to them being double-checked and commented, so watch this space!

 Error

Web Part Error: A Web Part or Web Form Control on this Page cannot be displayed or imported. The type could not be found or it is not registered as safe.

Error Details:
[UnsafeControlException: A Web Part or Web Form Control on this Page cannot be displayed or imported. The type could not be found or it is not registered as safe.]
  at Microsoft.SharePoint.ApplicationRuntime.SafeControls.GetTypeFromGuid(Guid guid)
  at Microsoft.SharePoint.WebPartPages.SPWebPartManager.CreateWebPartsFromRowSetData(Boolean onlyInitializeClosedWebParts)