When software attacks!

Thoughts and musings on anything that comes to mind

Powershell to find missing features in SharePoint 2010

When migrating from SharePoint 2007 to 2010, no matter how hard you try there’s always the chance the the content database upgrade process will throw out errors about features being referenced that are not present in the farm. We have used Stefan Goßner’s WssAnalyzeFeatures and WSSRemoveFeatureFromSite (see his original article) to track down the references and exterminate them. It’s not the fastest thing on two legs though, and I have a fondness for having my SharePoint 2010 tooling in PowerShell because of the flexibility it gives me.

Here then, with a big hat-tip to Stefan, is the PowerShell to replicate his functionality. We differ slightly, in that I wanted one command to purge both site- and web-referenced features in one shot rather than calling a command with a scope switch. I have two functions – get-spmissingfeatures takes a Site Collection url as a parameter and scans through site and web feature collections, listing any features with a null definition property. The second function, remove-spmissingfeatures takes the same url and this time finds and removes the errant features in one pass.

Get-SpMissingFeatures:

function get-spmissingfeatures([string]$siteurl)
{
  $site = get-spsite $siteurl


  foreach ($feature in $site.features) {
    if ($feature.definition -eq $null) {
       write-host "Missing site feature:"
       write-host $feature.DefinitionId
       write-host $feature.parent
#      $site.features.remove($featureid)
    }
  }

  $webs = $site | get-spweb -limit all
  foreach ($web in $webs) {
  foreach ($feature in $web.features) {
    if ($feature.definition -eq $null) {
       write-host "Missing web feature:"
       write-host $web.url
       write-host $feature.DefinitionId
       write-host $feature.parent
#      $site.features.remove($featureid)
    }
  }

  }

}

Remove-SPMissingFeatures:

function remove-spmissingfeatures([string]$siteurl)
{
  $site = get-spsite $siteurl


  foreach ($feature in $site.features) {
    if ($feature.definition -eq $null) {
       write-host "Missing site feature:"
       write-host $feature.DefinitionId
       write-host $feature.parent
      $site.features.remove($feature.DefinitionId)
    }
  }

  $webs = $site | get-spweb -limit all
  foreach ($web in $webs) {
  foreach ($feature in $web.features) {
    if ($feature.definition -eq $null) {
       write-host "Missing web feature:"
       write-host $web.url
       write-host $feature.DefinitionId
       write-host $feature.parent
      $web.features.remove($feature.DefinitionId)
    }
  }

  }
}

Enabling the TaxonomyFieldAdded feature to fix ManagedMetadata Column errors

We’re working on a solution at the moment that uses a custom site definition. For various reasons we stated with the Blank Site definition and worked from there. Our customisations include content types using custom columns that link to managed metadata term sets. We create all those through features – great! The tricky bit came when after deployment our managed metadata columns were greyed out. Examining the column we say an error telling us that the feature supporting the functionality was not activated.

What feature?

After quite a bit of hunting it turns out that there is a site collection feature called TaxonomyFieldAdded (ID 73ef14b1-13a9-416b-a9b5-ececa2b0604c) that is needed to allow the column to connect to the term set. The problem is that it’s a hidden feature so you can’t switch it on through the web site. Obviously we can enable it programmatically, but for anybody who has this problem (can’t connect a custom column to a term set) here is some simple PowerShell to enable it:

get-spfeature | where {$_Id –eq “73ef14b1-13a9-416b-a9b5-ececa2b0604c”} | enable-spfeature –url <site collection url>

Speaking at NeBytes in November on SharePoint for Content Publishing

On the 17th of November I’ll be keeping Richard company on the drive up to Newcastle to speak at the NEBytes user group. My session will be a shortened version of the Using SharePoint for Content publishing I will deliver at the Black Marble event on November 3rd. I will be showing what can be done with SharePoint 2010 when the brief is for a content publishing site, be it internet- or intranet-facing and I will talk about the things we have learned along the way whilst delivering such projects – things to avoid as well as things that work well.

Richard is talking about using Typemock Isolator in testing, providing the developer half of the usual NEBytes Developer/IT Pro split. The guys at NEBytes put a huge amount of effort into the community and it will be great to see Andy et al again.

Living with the Acer Aspire 1420P

This blog has been a very quiet place for a long time now, reflecting somewhat how busy I have been elsewhere. During this period of heavy work I have found a new friend in my Aspire 1420Tp In some ways it’s sad – my trusty and reliable Dell Mini 9 has been neglected in favour of a younger, sexier model.

tablet mode

The 1420P is the production model Acer convertible tablet, a variant of which was given to all Microsoft PDC conference attendees last year. We have quite a few in the office; sadly I am the only person to have paid for theirs. However, I benefit greatly from the fact that mine has a UK keyboard with all the right keys in their correct and proper places.

Personally, I think you get quite a lot for your money. For about £400 I have a lightweight, highly portable machine with ample power to perform the daily chores I give to it. I will admit that the first thing I did upon taking it from its box was to add a further 2Gb or RAM to its shipping quota of 2Gb, but many will not find the need to do so.

I thought long and hard before purchasing the 1420. I already have my workhorse laptop – the excellent TravelMate 6593 – which runs the things I need for the more technical aspects of my working life. However, it’s 15.4” frame weighs heavy when doing light work on the sofa in an evening, and it’s not great for casual web browsing.

I was finding myself more and more using my iPhone for casual web browsing, email reading and research. It was far easier than having a laptop on my knee, browsing with the touchpad and keyboard. I was seriously considering an iPad – the slate form factor and extreme usability were attractive. I had an eye on the HP Slate so loudly trumpeted b Steve Ballmer before it vanished frustratingly from view.

There were two problems with the iPad approach: Firstly, being a Yorkshireman, I found the price a little steep for an iPhone on steroids; secondly, and not unrelated to my opinion of the price, it was not as functional and flexible as I wanted.

The 1420P meets my needs ably. For casual web browsing, research and email it spends most of its life in tablet form, running portrait mode as I browse the web using nothing but the touch screen. When I use it for document writing or bits of sysadmin work it turns easily back to a traditional notebook form factor.

slate mode

It’s not perfect. The techy in me wishes that the touch screen was more than a mere 2-point variety; it would be nice if the display was a higher resolution than the now ubiquitous 1366x768, but that’s possibly because I am spoiled by the magnificent 1650x1080 of my TravelMate; the lack of a docking station connector makes it less convenient for use as a workhorse office computer; and it suffers in comparison with the iPad in terms of user interface for touch alone (this isn’t really the fault of the hardware, I suppose).

It’s qualities far outweigh the shortfalls, however. It weights almost nothing, and I can comfortably get eight hours from a full charge which means that the charger (itself small and lightweight) becomes an optional extra for short trips. The glossy screen is bright and clear (although like all glossy screens it suffers in bright light) and does not suffer like the Dell Mini when browsing the web; the keyboard is comfortable and responsive to use and causes me no trouble when working on long documents; finally, and my favourite part, when in tablet mode it is comfortable to hold and natural to use.

Which brings me to something I find really significant about convertibles. When I’m in a meeting I hate using a laptop. I find that the screen immediately forms a barrier between participants and I hate thinking that behind that barrier the person could be doing something other than concentrating on the x7686meeting. I prefer to use a pen and paper as a result, but that means I need to transcribe notes later. The convertible 1420 allows me to switch to tablet mode and use OneNote and the stylus. I have all the benefits of a computer in front of me so I can access documents, email and other resources on demand, but the computer does not come between me and the other attendees. OneNote also allows me to quickly generate notes, tasks, actions and more without leaving the application.

Specification:

Size 285 x 208.9 x 28.5 mm
Weight 1.72kg
Screen Resolution 1366x768
Multi-touch 2-point
Processor Intel Celeron U2300
Memory 2Gb (upgraded to 4Gb)
Hard drive 160Gb
Price approx. £400

Powershell script to rename files for use as SharePoint 2010 User Profile thumbnails

User profile photos have changed in SharePoint 2010 in that they are now stored in a single image library in the MySite Host root site collection. They have also changed in that when you change the profile photo, SharePoint takes the file and creates three new images at specific sizes, then discards the file you gave it. These files have specific names to link them to the user account and come in small, medium and large flavours.

We’ve just delivered a solution to a customer that involved heavy customisation of the Profile page for users. This also involved replacing the large thumbnail version of the profile picture with one which met our size requirements.

The customer had a large group of image files all named in the pattern <firstname surname>.<extension> which had been loaded in to SharePoint as profile pictures. We wanted a quick way to replace the large thumbnail with our own version.

Enter Powershell, stage left. The script below is a little rough and ready but works great. It gets a directory listing, splits the filename and then looks up in AD to see if there’s a user that matches the filename (sans extension). If it finds a match it renames the file to match the pattern <domain>_<SamAccountName>_LThumb.<extension> to match the profile picture naming convention.

As I said, it’s a little rough and ready but I place here for the greater good. You need the ActiveDirectory powershell module to use this. It’s available on Server 2008 and above, and Windows 7 if you install the remote management tools.

The Active Directory Powershell Blog is a great resource for this stuff!

#import-module ActiveDirectory
if (-not (get-module -name activedirectory)) {
    write-host "This script requires the ActiveDirectory powershell modules to run"
    exit
}
$domain="mydomain"
$filesuffix = "LThumb"
$files = get-childitem
foreach ($file in $files) {
    $filesplit = $file.Name.split(".")
    $fullname = $filesplit[0]
    $fileext = $filesplit[1]
    write-host "Searching for:" $fullname
    $user = get-aduser -Filter { Name -eq $fullname }
    if ($user.SamAccountName -eq $Null) {
        write-host "Not Found!"
    } else {
        $newfilename = $domain+"_"+$user.SamAccountName+"_"+$filesuffix+"."+$fileext
        write-host "Renaming:" $file.name "New name:" $newfilename
        rename-item $file.Name $newfilename
    }
}

Thoughts on the BCS EGM

Stepping along the path ploughed by Richard and Robert, I thought I’d try to order my thoughts on the BCS EGM through a blog post. Like Richard, I am (as I begin writing) uncertain as to my final leaning on this, although I have clear views on some of the issues.

Democracy In Action

One of the most important, in my view, is one which might be missed by many. Should the membership vote in favour of the Board of Trustees they are also strongly encouraged to change the bye-laws of the Royal Charter to stop this happening again.

For me, that is an atrocity and should not be allowed. That’s a strong word, so let me explain why.

The membership of the BCS is being swelled through the push for a higher profile. That’s a good thing, no doubt. However, two percent of an ever increasing membership base quickly becomes a large number of people. The time and effort involved in trying to marshal that many people to raise an object to how the BS is working effectively means that it will never happen. I believe that to be incredibly undemocratic.

Furthermore, the kind of member who is likely to pay enough attention to the actions of the BCS to raise an objection is much more likely to have attained a higher level of membership, such as Fellow. There aren’t many of those about, and I’ll wager that there certainly aren’t enough to amount to two percent!

Arguably what we are currently experiencing is a good thing. A group of highly committed members have used the mechanisms embedded in the charter of our professional body to put the brakes on a process which they believe requires greater scrutiny by the whole membership. Should the EGM vote go against those members, they should still be commended for having the courage and commitment to the BCS that they fought to initiate the process at all.

For the good of the members

The purpose of a professional body such as the BCS is to provide those outside of our industry with a recognisable ‘Kite Mark’ of quality when it comes to engaging the services of IT practitioners. Everything else that the organisation does should revolve around that most important premise.

If we follow the line of reasoning which identifies the activities which must flow from the above aim we will quickly find ourselves in the heart of the current argument.

Affirmation of Qualifications

Other professional bodies are extremely careful about how their members qualify for the professional qualifications they offer. This is a critical matter, in that it underpins the level of trust the outside world places on the body in question and its assertions as to the professionalism and trustworthiness of its members.

It worries me, therefore, that current implications suggest CITP seems to be a qualification along the lines of a Readers Digest competition – fill in the form, everybody must win!

It worries me even more because, as someone who is not a developer, the more rigorous path of CEng is not open to me. For IT professionals like me, the CITP must be a thorough assessment of the skill and integrity of the bearer or it becomes worthless.

I say this as somebody who has achieved CITP status. When I went through the process the level of detail I had to provide was actually quite high, and references were needed from other members of the BCS who were already of Chartered status (CITP or CEng) or higher. Had I not worked in the industry for so long, with such a varied wealth of experience from different roles, I am not sure I would have made the grade. That is absolutely how it should be.

The very fact that there are those within the BCS who cast doubts as to the validity of the CITP status inherently means that there are doubts as to that validity and it is therefore of far less value. This is a rapidly accelerating downward spiral which has important ramifications for the body.

Promotion of the Body and its role

There is no point having a professional body which underwrites the quality of practice in its industry if nobody is aware of it. For many years, working in IT, I dismissed the BCS as a group of fusty academics who were not in touch with the rapidly moving industry that I loved to be a part of. That the current BCS management have been striving to change that is to be applauded.

IT is an still immature industry. With such immaturity and rapid change there will inevitably be crises. It is the role of the BCS to wade into all these and advise, mediate and in some cases dictate in line with the levels of professionalism it seeks to underwrite in the industry. It cannot perform that role if nobody is aware of its existence.

At the same time, however, the BCS is, in reality, somewhat of a toothless tiger. We do not work in an industry where lack of professional qualifications is a barrier to practice. Perhaps that is wrong, perhaps no; there are very clear arguments to be made in favour of both views.

Sacrificed on the alter of our own success

IT as an industry has a problem. Some aspects of it, one can argue, fall into a similar professional services area to those of the legal and accounting professions. You would never hire an unqualified and unregulated accountant, so why should you use IT professional services that are not similarly regulated.

Many IT projects, particularly for large organisations and functions where lives are at stake, are held up as abject failures and stain the reputation of our industry. Would the threat of being cast out of the BCS and therefore being unable to continue to practice improve the level of conduct and professionalism of those involved in such projects? Who can say?

At the same time, however, ours is an area of extreme innovation at a pace so rapid as to be frightening. A prescriptive professional body might prevent such innovation (or at least force it outside the UK, which helps nobody). In areas such as the web, technology advances faster than any regulations could cope with, however responsive to change they might be.

That second situation demands a body more in line with the other engineering disciplines. They are looked upon to provide a guarantee of skill, knowledge, approach and practice to give confidence in those consuming the services of their practitioners.

Ultimately, the BCS has now reached a point where it does none of the above:

  • There is no regulation of our industry, so the BCS is not an institution which safeguards quality of practice.
  • The CITP has little value in the eyes of many because they perceive it to be to easy to achieve and too little scrutinised.
  • If the CITP is to easy, what does that say for the CEng awarded by the BCS?
  • What good is self promotion if it merely promotes your own inadequacies?

Where does this leave the BCS? I would seem to be approaching a bleak conclusion!

Summation

It is clear that careful examination of the issues driving the actions which have led to the EGM takes us down an existential rabbit-hole. Let us then zoom out and ask some simple questions which might help us (I am not going to answer them – you must answer them for yourself and let that guide your vote):

  1. Can we find information that tells us what the current management are doing, not just in broad strokes that outline a strategy but in more detail as to the implementation of that strategy?
    If the answer is yes, then we have the transparency which those who have called the EGM have implied does not exist. If not, then the arguments of the dissenters have obvious validity.
  2. Are we comfortable with management that, faced with a situation which is uncomfortable for them (the EGM) wishes to change the constitution of the organisation to prevent the situation ever occurring again.

Conclusion

I think I have come to a conclusion during the course of writing this. What  will happen after the vote? If the outcome does not meet my own convictions should I look to leave the BCS? If, as I appear to have concluded, I have low confidence in the CITP qualification I hold, should I remain a member of the body which awarded it?

Oddly, my opinion on this is clear. Yes. The pain within the BCS reflects the pain within the IT industry. That there should be a professional body within IT is clear. That the BCS is currently the only game in town is also clear. We should therefore continue to strive to make the BCS what it must be – the guarantor of quality and trust within the industry.

You can only affect change from within.

It works! 8Gb RAM in my Acer TravelMate 6593

I thought I’d post this because so many like me might benefit from my experiment. We have a number of Acer TravelMate 6593 laptops here at Black Marble. They’re great machines – plenty of grunt, a lovely screen and most of the toys you could need in a laptop that’s used for a mix of IT admin, dev and technical sales (including demos). The only downside is that they only ship with up to 4Gb of memory, and Acer say it won’t take more.

I’ve wondered about that for while – all the documentation I could find said that the system supported 4Gb SODIMMs in the two memory slots and the Intel chipset inside supports more than 4Gb of memory.

The cost of two 4Gb SODIMMs for experimentation always stopped me. However, the now lower price, combined with an absolute requirement to run the SharePoint 2010 IW virtual machines (which need 8Gb to fire up!) made me take the plunge.

The good news is that two DDR3 4Gb SODIMMs from Crucial arrived, were installed and worked first time. The system booted with no errors, Windows 7 (x64) recognised 8Gb of memory and a quick bit of partition shuffling later I had a dual-boot Windows 7/Server 2008 R2 + Hyper-V laptop. Marvellous.

Obviously, your TravelMate might not be as accommodating as mine, so make sure you check the returns policy on your RAM!

Solving a mystery: Windows 7 games won’t work on HP TouchSmart TX2

This one has been nagging at me for a long time. My grandmother has an HP TouchSmart TX2 tablet. It was bought with Windows Vista, but as with her main computer, I upgraded it to Windows 7.

It was a good plan – Windows 7 should make it perform better, and the touch capabilities of 7 are better than Vista. There was, however, a small matter of the N-Trig digitiser drivers not being great at point of release – something which would lead me down the wrong path over the problems I encountered.

Windows 7 went onto the TX2 with no problems, except for the phone call I got soon after the rebuild – Mah Jong wouldn’t load, and Tinker (courtesy of Live) was crashing on startup.

Weirdly, when I looked at the system, they all ran when I was logged in as an admin user. However, my standard user-level grandmother got errors. I played with UAC and discovered that having switched it off, rebooted, run the games, switched UAC back on and rebooted again, they worked.

I told myself that it was something to do with the recently-installed N-Trig drivers not having configured things right (the last change to the system) and went away. Except things weren’t working…

The next time, I spent hours examining the system using Process Monitor and Process Explorer. I was thinking that file rights or registry rights would be the culprit, as the games still worked for the admin user. Sadly, I found no errors, no access denied messages, no failures at all. Still things didn’t work.

I’d largely given it up as a bad job, until today, when I installed the Touch Pack. I thought that the additional games might be fun for my Grandmother to play. Had they worked… The newly installed games failed in the same way as Tinker – a shiny ‘program has stopped working’ message and nothing more.

When I tried Bing Maps 3D, however, I got a different error. There in front of was a message about being unable to initialise the Direct 3D system, and so Maps 3d couldn’t load.

Aha! I thought. I downloaded the ATI graphics drivers for the Mobility Radeon 3200 and installed the latest set. No difference.

So I resorted to the hive-mind of the web again. This time I found a thread on a Microsoft forum talking about a problem with ATI drivers properly recognising the hardware at install time on the TX2. That sounded promising, and led me to the AMD support article. Unfortunately, installing the hotfix drivers still didn’t work.

I then found another article on a Microsoft forum talking about a similar issue, fixed with a BIOS update. I hadn’t thought about a BIOS update for the TX2 – I tend not to think about that kind of thing when it’s not my PC. Sure enough, the TX2 had an older BIOS (version F.03) than the latest on the HP site – F.25.

Updating the BIOS still didn’t fix things, but I then reinstalled the ATI drivers supplied by the hotfix article and that did it. All the games worked, Tinker fired into life, and Bing Maps 3d started without a problem. before the driver reinstall I got a slightly more informative error from the games saying ‘A problem has occurred with the 3d driver’.

So, if you get the same problem, here is a quick summary:

Symptoms:

  • Windows 7-included games fail to load. Click the icon to fire them up and nothing happens.
  • Microsoft Tinker dies on startup.
  • Microsoft Touch Pack games die on startup.
  • Bing Maps 3D says it failed to initialise Direct3D.

System:

  • HP TouchSmart TX2 tablet, model 1015ea

Solution:

Unable to remote control Hyper-V VM after installing SharePoint 2010 on Windows 7

True to form, you only discover something isn’t working when you’re in a desperate hurry. We use lots of Hyper-V VMs here at Black Marble and they are mostly running on our four node cluster. I use Failover Cluster Manager and this morning I couldn’t connect remotely to any of the Hyper-V VMs. I kept getting an error:

Virtual Machine Connection:
A connection will not be made because credentials may not be sent to the remote computer. For assistance, contact your system administrator.
Would you like to try connecting again?

A quick search suggested that the credssp settings on the host servers were broken. A quick test showed that they weren’t – the problem was local to my machine.

The only thing I had changed recently (try yesterday!) was to install SharePoint 2010 on my workstation. OK, I’ll be fair – that means a whole load of pre-requisites, so it’s not that simple!

I decided to check my machine and look at the settings which had been suggested as being wrong on the hyper-v servers. Sure enough, my workstation now had the credssp elements and sure enough, they didn’t match the example I’d found.

So if you get the same problem, copy the text below into a .reg file and import it into your registry. It should fix the problem.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\Credssp\PolicyDefaults]
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\Credssp\PolicyDefaults\AllowDefaultCredentials]
"Hyper-V"="Microsoft Virtual Console Service/*"
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\Credssp\PolicyDefaults\AllowDefaultCredentialsDomain]
"Hyper-V"="Microsoft Virtual Console Service/*"

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\Credssp\PolicyDefaults\AllowFreshCredentials]
"Hyper-V"="Microsoft Virtual Console Service/*"

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\Credssp\PolicyDefaults\AllowFreshCredentialsDomain]
"Hyper-V"="Microsoft Virtual Console Service/*"

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\Credssp\PolicyDefaults\AllowFreshCredentialsWhenNTLMOnly]
"Hyper-V"="Microsoft Virtual Console Service/*"

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\Credssp\PolicyDefaults\AllowFreshCredentialsWhenNTLMOnlyDomain]
"Hyper-V"="Microsoft Virtual Console Service/*"

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\Credssp\PolicyDefaults\AllowSavedCredentials]
"Hyper-V"="Microsoft Virtual Console Service/*"

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\Credssp\PolicyDefaults\AllowSavedCredentialsDomain]
"Hyper-V"="Microsoft Virtual Console Service/*"

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\Credssp\PolicyDefaults\AllowSavedCredentialsWhenNTLMOnly]
"Hyper-V"="Microsoft Virtual Console Service/*"

Fixing SharePoint 2007 IIS WAMREG DCOM 10016 activation errors on Server 2008 R2

Anybody who works will SharePoint will grumble if you mention DCOM activation permissions. No matter how hard we try, how many patches we install (or how hard we try to ignore it), granting activation and launch permissions to the SharePoint service accounts is like plugging a dike with water-soluble filler.

On Server 2008  R2 our job is made that much harder by the fact that, by default, even administrators can’t edit the security settings for the IIS WAMREG service (GUID {61738644-F196-11D0-9953-00C04FD919C1}, for when you see it in your application event log).

The fix is to change the default permissions on a registry key, which you can only do by taking ownership of the key. My only comment would be that those permissions were locked down for a good reason in Server 2008 R2 and it’s somewhat frustrating that we need to do this.

Anyway, the key you are looking for is:

HKEY_CLASSES_ROOT\AppID\{61738644-F196-11D0-9953-00C04FD919C1}

To change the ownership you need to click the Advanced button in the Permissions tab of the properties dialog, then select the Owner tab. I’d recommend changing the owner to the Administrators group rather than a specific user, and make sure the permissions for TrustedInstaller are the same after you finished as they were before you started.

Once done, you can edit the DCOM permissions for the IIS WAMREG service in the same way as on other versions of Server 2008.