Monday, December 27, 2010

Attaching to IIS Worker Process Server 2008

Here's the situation: You want to attach to an already-deployed web application, but you need to know which worker process is running your application. You've discovered that the trusty iisapp script you've used for years is gone.

That worked fine, so Microsoft decided to change it in Server 2008. The script is gone and replaced by an executable called APPCMD.

To list the process IDs for each worker process:

APPCMD list wb

The program is located in C:\Windows\System32\inetsrv. If you do this regularly, you should think about adding it to your system path.

Thanks to Carey Roth for running this down for the rest of us.

Wednesday, December 22, 2010

More About Removing Site Columns

Even after you've removed lists or content types that use site columns, you may still not be able to remove them.

That may well be because they're in the recycle bin.

In SharePoint 2010, the recycle bin is two tiers deep. Users can empty their recycle bin but the site collection administrator still needs to empty theirs before the object is really and truely gone.

To do this (if you are a site collection admin, of course):

1) Site Actions -> Site Collection Administration -> Recycle bin
2) Select all the files (can be done in one step by clicking on the header) and pressing the "Delete Selection" button on the ribbon control.
3) Click on the "Deleted from end user Recycle Bin. All the things you just deleted are now here.
4) Select everything and click the "Delete Selection."
5) Press "OK" to the warning about permanent deletion.
Of course, you can turn off the recycle bin or change the hold times. Here's how.

Friday, December 10, 2010

Finding Content Type References to a Site Column

If you try to delete a site column that is being used by one or more content types, you'll be rewarded with this message:

"Site columns which are included in content types cannot be deleted. Remove all references to this site column prior to deleting it."

That's true, but finding these conent types is not an easy matter. After some searching, I concluded that none of the approaches suggested are very efficient. Existing approaches are:

  1. Brute force. Search all the content types in all the sites and sub-sites on your farm.
  2. Use the Content Query Web Part. (I'm not actually sure this works)
  3. Write code based on the SharePoint API. (Time consuming)
  4. Rename the column (Doesn't work).

Here's a more efficient alternative: Look in the content database. The following query returns a list of webs and lists using a site column:

select ctu.ContentTypeId, w.FullUrl, l.tp_Title from ContentTypeUsage ctu
inner join Webs w on ctu.WebId = w.Id
inner join AllLists l on ctu.ListId = l.tp_ID
inner join ContentTypes ct on ct.ContentTypeId = ctu.ContentTypeId
where ct.Definition like '%Your Column Name Here%'

This returns the name of the content type ID of the field, the site and list name where it is used.