Nick Hadlee's Blog on SharePoint and Other Occasional Rants…


PowerShell and SharePoint Scripts from Tech.Ed NZ and Code Camp 2011
August 31, 2011, 9:59 pm
Filed under: 2010, Administration, PowerShell, Presentations

I recently did a PowerShell and SharePoint session at Tech Ed NZ 2011 and then again during Code Camp in the following weekend. The focus was on using PowerShell to create and configure a SharePoint portal and as promised here is a list of the scripts I used during my demo.  These scripts and a couple other useful files are in my SkyDrive so you can go and grab them individually. The whole lot is in the same place as a zip too.

This is the order that I showed and used them (or intended to):

  1. Add a managed account
  2. Add and configure a web application
  3. Add the managed metadata service application (Didn’t run this one just showed it)
  4. Adding site collections
  5. Configuring and adding content databases
  6. Backup and restore the farm, a service application and/or a web application (Didn’t run this one just showed it)
  7. Backup and restore a site collection
  8. Start a search crawl
  9. Add some sub sites
  10. Change the site collection properties to point to a search center
  11. Change the site properties to use alternate CSS and a site logo
  12. Adding users to the sites and adding a second site collection administrator
  13. Walkthrough of the web hierarchy (webs, lists, list templates, content types, fields)
  14. Basic deploy of solutions (WSP’s)
  15. A better way to deploy solutions
  16. Turning on the developer dashboard
  17. Checking the ULS

Note: These scripts were kept pretty simple to make them easy to read and describe during the demo. I’d strongly recommend you add a bit of error checking, maybe a few if/check statements etc before just running them willy nilly. Also some things were commented out during the sessions – uncomment them at your leisure.

Code Camp Slide Deck

The Code Camp slide deck is more or less the same as the Tech.Ed one.



What’s in Your SharePoint Toolbox?
September 19, 2009, 8:50 pm
Filed under: Administration, Development, SharePoint, Tools

This is both a thank you SharePoint community post and also another one of those resource listing posts. I think it is pretty fair to say the Community has provided many people with many of the tools and information that make our jobs easier. Acknowledging what has been helpful both recognises the Community and might direct people to something that they are looking for.

The massive end-user, IT pro, and developer community that has evolved around SharePoint has shared a rich set of tools, best practices, and guidance for the wider benefit of the SharePoint community. It should be mentioned there is also a lot of stuff out there in the wild that shouldn’t be adopted but I think that is the nature of all information on the internet.

Although we are drawing much closer to the public unveiling of SharePoint 2010, it is unlikely it will be available to the large majority of users until some time mid-next year (2010). In between then and now guidance around best practice will emerge and a whole new set of tools will be created and shared. The success of the current version of SharePoint (the huge number of WSS 3.0 and MOSS 2007 deployments) means the current set of tools will continue to be useful and necessary for some time yet.

So in no particular order…

SharePoint Administration / Deployment

  • SharePoint Manager 2007 – one of the most useful tools for SharePoint administrators and developers. It combines many of the features of the central administration, site settings menu and the SharePoint object model into a well-structured and easy-to-use GUI. The ability to inspect and possibly change almost any object/property in the SharePoint Farm makes it a really useful…SharePoint Manager.
  • SharePoint Content Deployment Wizard – this pretty much does what it says – it’s a content deployment tool with a friendly wizard driven interface. Chris O’Brien has developed an GUI for SharePoint’s native deployment API. Therefore, Content Deployment Wizard is a fully supported method of moving content between environments – it’s essentially the same process as used by STSADM’s export/import commands but it has more granular options. Among other things the Content Deployment Wizard lets you perform selective migrations using a nice GUI – really helpful when you only want to migrate a specific list or web instead of the entire site.
  • SharePoint Automation – these custom STSADM extensions by Gary LaPointe provide administrators with a huge number of additional operations that cannot be performed with the out-of-the-box STSAM commands. Often these would be things you would need to develop a custom (even throwaway) script for. At last count there were 143 commands and a growing set of PowerShell cmdlets.
  • Microsoft SharePoint Administration Toolkit – although not a community tool, this is a set of additional administration tools for both WSS and MOSS produced by Microsoft. There is a full overview on the SharePoint Team blog that explains in detail how the “[toolkit provides] functionality to address various difficult administrative tasks…[including] SharePoint Diagnostics Tool improvements, the Permissions Reporting Tool, the Quota Management command, and Security Configuration Wizard Manifests”. See the SharePoint Team blog for the download links, installation instructions and other useful documentation.

SharePoint Development

  • SharePoint Search Service Tool – allows you to connect to the search service of either MOSS or WSS via their web services. This is particularly helpful in inspecting the available scopes, managed properties, output of the search index and actually building the search queries. Using the SharePoint Search Service Tool’s GUI you can “build queries in either Keyword or SQL Syntax, submit those queries and examine the raw web service results”. The SharePoint Search Service Tool is useful not only in building up the search query syntax for reuse in web parts but as mentioned on the tools Codeplex homepage, it is very useful for “troubleshooting and verifying the behavior and configuration of a SharePoint environment”.
  • U2U CAML Query Builder – CAML queries are pretty difficult to write unless they are really trivial, and even the the syntax is easy to get wrong if you are doing it by hand. Luckily the good people from U2U have provided an interactive GUI that can connect to SharePoint and help you build the query and interactively inspect the results. Given the pervasiveness of CAML queries throughout SharePoint, this is one tool that is very useful for any SharePoint development.
  • STSDEV – a great alternative to the Visual Studio extensions for SharePoint Services (VSeWSS). It is, or should be, a well-known best practice that features, files and other customisations should be deployed to SharePoint using solution packages (WSP’s). STSDEV, VSeWSS and other Visual Studio add-ins, such as WSP Builder, provide an integrated method to package up the artefacts either created from, or included with a Visual Studio project into a deployable SharePoint solution file.
  • Warmup Scripts – SharePoint, like any ASP.NET application, is really slow for the first request to a page in the web application. This is because IIS and ASP.NET have to do an initial just-in-time (JIT) compile for that first request, which happens after an IISReset or application pool recycle has occurred. Most SharePoint application pools are set to recycle every night so this is always going to affect at least one user in the morning. Warmup scripts address this issue by making that first request to ensure the pages are compiled and ready to be served. There are many different flavours of warmup scripts including the SharePoint Warmup Job by Andrew Connell that manages the warmup requests from central admin and the Application Pool Manager by Spencer Harbar that allows both the recycling and warming up of application pools.
  • SharePoint Designer – everyone (should) know about SharePoint Designer by now, especially since it was made free by Microsoft. This powerful editor for SharePoint sites shouldn’t be dismissed by developers; the powerful dataview/dataform web part is an example of something that can be “developed” using SharePoint Designer.
  • CodePlex – this is where a large amount of the useful community tools and projects can be found. The MOSS Faceted Search, Community Kit for SharePoint and SmartTools for SharePoint are just a few examples and the list goes on.

Web Development

  • Firebug (for Firefox) – possibly the most useful web development tool ever – that’s a pretty big statement but I firmly believe it! Firebug is a Firefox plug-in (it has a sort-of-IE-version) that allows for the live inspection, editing and debugging of the HTML, CSS and JavaScript of a page. The CSS inspector is extremely useful when trying to track down what style rules are being applied to a specific element (and how they can be overridden in the case of Core.css).
  • YSlow (for Firefox) – “analyzes web pages and suggests ways to improve their performance based on a set of rules for high performance web pages” and is a must for anyone who is trying to improve the performance of a page. The rules that YSlow uses to determine the performance of the page all have recommendations on how they can be implemented. This is an excellent tool for improving page/site performance.
  • Fiddler – allows for the inspection of the HTTP traffic between your browser and the server. This includes all of the images, CSS and JavaScript that makes up the page and shows the HTTP codes, load times, compression settings and a myriad of other information for really inspecting what is happening during those requests. Firebug, YSlow and Fiddler all complement each other well and are an absolute must for any performance tuning of SharePoint pages and sites.
  • jQuery – the jQuery JavaScript library deals with many of the issues of cross-browser support then adds a huge set of methods “…that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development”. It’s a Swiss-army-knife for web development and one method of customising SharePoint to enhance the users experience.

General Development

  • RedGate .Net Reflector – is a free .NET assembly explorer. This tool is especially useful to check what version of the dll’s are being deployed with your SharePoint solutions – i.e. did I set the build to debug or release mode?
  • WinMerge – sometimes you just need to compare the difference between two files and WinMerge is great for quickly comparing and finding those differences.
  • EditPad Pro – this is notepad “on steroids”. There are a lot of alternative text editors available but EditPad’s built-in regular expression engine which then provides support for regular expressions during find and replace is invaluable.
  • Log Parser Lizard – I have only used this tool a few times but it was so helpful that I thought it was worth mentioning. Also the credit goes to Todd Klindt as I came across it on a blog post of his. In a nutshell, Log Parser Lizard is a GUI for Microsoft’s Log Parser. Log Parser allows for SQL-like syntax to be used to query text-based data such as log files, XML and CSV files. Log Parser Lizard wraps the complexity of the command-line operations of Log Parser into a nice GUI and includes lots of pre-canned queries out-of-the-box.

SharePoint seems to be the type of product where there is more than one tool to achieve a task and often there is the need for more than one tool to complete that task. These are the tools that I have used consistently and found really helpful and I know there are a lot more out there than this less-than-exhaustive list. If you have any really good tools that you would like to share then please leave a comment.



Search Service, Anonymous Access and 401s
July 7, 2009, 11:26 pm
Filed under: Administration, Authentication, SharePoint

In another semi-related post I was talking about anonymous access in SharePoint and a work around that can be used if you need to force authentication to work at the same time. It is as counter intuitive as it sounds…

An unexpected side affect of anonymous access can be that SharePoint web services might not work as expected. This certainly was the case in the situation I described in the other post but luckily Dave Wollerman describes a fix for this issue.

An issue I can see arising is when you start to disconnect what SharePoint is managing – configurations via central administration – versus what you are now directly responsible for managing with IIS then your maintenance headache increases. For example: In a farm you will need to make sure all front-ends are synchronised by changing the IIS settings on each server.



When an Index Server Can’t Stop ‘Stopping’
May 27, 2009, 11:10 pm
Filed under: Administration, SharePoint, SQL, Troubleshooting

Due to some erratic behavior with a farms index server it was necessary to uninstall the indexing role and then re-provision it. The problem was during the uninstall the index service got stuck in a stopping state. A quick check in the error logs pointed to the SQL server. The SQL server logs were a little more descriptive with a 17310 event and even included the words ‘fatal’:

Event Type:    Error
Event Source:    MSSQLSERVER
Event Category:    (2)
Event ID:    17310
Date:        M/dd/yyyy
Time:        h:mm:ss yy
User:        N/A
Computer:    xxxx
Description: A user request from the session with SPID XXX generated a fatal exception. SQLServer is terminating this session. Contact Product Support Services with the dump produced in the log directory.

I have found when troubleshooting Google can either be a savior or a massive run-around, usually it depends on the reliability of the source and how good your searching skills are. In this situation what appeared to be a Chernobyl-esq problem had been encountered by a few people and ensuring that service pack 2 was installed on the SQL Server was the recommended fix. After applying the service pack the SQL logs were clear and the index service was able to be uninstalled and re-provisioned.

Unresolved Questions

The biggest question in the aftermath was why was a production SQL server not running the latest service packs? Surely someone has neglected their duties?

The infrastructure guy responsible for the SQL server has an interesting theory, especially if you like the implausible, the current blame for this issue was the installation of the SQL business intelligence studio onto the server which downgraded the SQL dll’s back to the RTM version. This will make a interesting test and would represent a massive bug if it was the case. Has anyone come across this or something similar before? It wouldn’t be the first software bug and it won’t be the last…




%d bloggers like this: