Powershell tip - find all checked out files

I needed to quickly find all files in a particular web that were checked out. I immediately went to Powershell, and after hacking about for a few minutes did what I should have done first - Google’d it. Doing this revealed that Gary had already done the bulk of what I needed to do. However, I made a couple of changes, namely that I only wanted it to traverse a specific web, but I needed it to traverse any subwebs in that web and lists.

Read more

Quick tip: SharePoint powershell - get items in a list based on custom columns and other hints

This may be handy when trying to find specific items in a list based on values of various fields:

$web = Get-SPWeb http://yourweb
$list = $web.Lists["Your Library Name"]

// this is the bit - get items of a particular content type
// ? is shorthand for where, and $_ is the item in the pipeline
$listItems = $list.Items | ?{$_.ContentType.Name -eq "Content Type Name"}

// or items based on a custom column - if using -like then the wildcard is *
$listItems = $list.Items | ?{$_["InternalFieldName"] -like "*this*"

// you could join them up using -and
$listItems = $list.Items | ?{$_.ContentType.Name -eq "Content Type Name" -and $_["InternalFieldName"] -like "*this*"

// or iterate the loop and print them out
foreach($item in $listItems) { Write-Host $item.Name, $item["InternalFieldName"] }

or more directly

$list.Items | ?{$_.ContentType.Name -eq "Content Type Name" -and $_["InternalFieldName"] -like "*this*" | foreach { $_.Name, $_["InternalFieldName"]

// or count them
$listItems.Count

or

$list.Items | ?{$_.ContentType.Name -eq "Content Type Name" -and $_["InternalFieldName"] -like "*this*" | foreach {$count++}
$count

Powershell can be infuriating - but when you find the syntax, it can be pretty helpful.

Read more

SSRS error: Operation is not valid due to the current state of the object

If you’re using SSRS in SharePoint integrated mode, you may come across this error when using report parameters that have a high number of items in them. A recent security bulletin highlighted some issues and vulnerabilities in ASP.net, and a patch was released to cover some of the items. One of these was the maximum number of items you can have in a collection. If you exceed the limit, then you’ll likely get an error like:

Read more

SharePoint 2010 Foundation + SQL Server Reporting Services Integrated mode installation issues: Failed to establish connection with report server, 401 errors and more

You may be trying to set up SharePoint 2010 to act as the report repository for SQL Server Reporting Services report. This is a pretty nifty feature, especially as it’s available in the Foundation (i.e., Free) version of SharePoint. There is a pretty exhaustive guide on how to set it up and for extra help, this blog post is pretty good too, and if you follow the steps, you get pretty far. However, if you’re in a multiple server setup (i.e. your SQL server isn’t on the same server as your Central Admin) you will likely encounter configuration issues surrounding authentication, and there is a great deal of confusion about what it all means - especially when it comes down to Kerberos. That’s beyond the scope of this post - what I’m covering here is one very annoying issue that there was no definitive answer to on the web.

Assuming you get all the server parts setup and Reporting Services configured, you might find that you can browse to your report server address on the machine hosting reporting services, but, if you try to browse to that address from anywhere else, you’ll get an endless stream of login boxes, and no credentials will work. Also, if you go to Central Admin and go to General Application Settings > Reporting Services Integration, when you fill in the details to connect to reporting services, you’ll hit an error like:

Failed to establish connection with report server. Verify the server URL is correct or review ULS logs for more information. Product area: SQL Server Reporting Services, Category: Configuration Pages

and, in the ULS logs, an error like:

SQL Server Reporting Services Configuration Pages Failed to retrieve RS configuration information: System.Net.WebException: The request failed with HTTP status 401: Unauthorized.

Here’s how I fixed it my workaround.

Read more

The search service is not able to connect to the machine that hosts the administration component

Another example of “when SharePoint goes wrong.” On a dev machine, the search service mysteriously stopped working. I can’t pinpoint what caused it, but SP1 and a CU were recently applied and these seem like good candidates for breaking things. When trying to admin the search service, you would see the following error:

The search service is not able to connect to the machine that hosts the administration component. Verify that the administration component ’{guid}′ in search application ‘Search Service Application’ is in a good state and try again.

…and trying to modify the topology of the search, resulted in a spurious error:

An unhandled exception occurred in the user interface.Exception Information: Exception has been thrown by the target of an invocation.

Something was clearly unhappy. Rather than waste too much time, the simplest solution seemed to be to delete the search application and recreate it, which I duly did, via Central Admin, verified that DBs and application pools disappeared and recreated the search application, using new names and credentials. Same error. I wasted spent some looking at permissions and the usual array of logs, events and other candidates, ran PSConfig and other upgrades, all to no avail.

I figured I could create the search application via Powershell. Why should this make a difference? No idea, but worth a shot. Then thankfully, I found that someone had already done it for me. And yes, this resolved the issues. I can’t explain why seeing as this script shouldn’t do anything that the GUI doesn’t do.

Script:

Read more

Error formatting query, probably invalid parameters [SQLSTATE 42000] (Error 22050)

I just tripped over this problem, and despite a fair amount of Googlage, I didn’t find anything that directly resolved my issue. I was trying to use dbMail in SQL Server 2008 to send an email on a schedule which included the results of a query. Doing this should be fairly straightforward, by executing the sp_send_dbmail stored procedure, which is in MSDB:

This query works fine in SSMS, but when run as a SQL Server Agent Job, it fails, with the error

Read more

Useful SharePoint script to restart SharePoint services and IIS

A SharePoint developer’s life is filled with many things, but one of the most common is the old faithful iisreset, coupled with a reset of the Timer Service and the Admin Service. When you’re working on timer jobs, it can get tedious quickly to have to  keep resetting things.

So I’m sharing a useful batch script I knocked together to do it for you. It will perform three functions - restart the SharePoint 2010 Timer Service, the SharePoint 2010 Administration Service and do an IISReset. It will prompt you if you want to do each of them, and if you don’t reply within 5 seconds automatically do it.

Read more

Configuring certificates and trust in SharePoint 2010 for accessing Exchange Web Services

Exchange is built on web services and as I posted about a while about accessing EWS from SharePoint can be pretty neat. There is a managed API to make your life even easier. However, one issue you may come across is actually getting SharePoint and Exchange to talk nicely to each other. This will walk you through some of the steps required to get things going.

Read more

SharePoint 2010: The filename, directory name, or volume label syntax is incorrect

This is a peculiar little bug. When creating a List Definition, you may encounter the following error when you try to deploy:

The filename, directory name or volume label syntax is incorrect.

It took a while to track the cause, seeing as a lot of info out there info out there relates to things to do with file systems, which in this case, obviously wasn’t the cause.

The bug for me was that I had created a List Definition and called it My.List.Definition - notice the multiple periods. I wanted it to match the namespaces that we were using. It turns out that the second period trips it up. When you create a List Definition with multiple periods, the List Definition only gets the first period, e.g., My.List, whereas the Elements.xml file for the List Definition still references My.List.Definition - hence it can’t deploy properly.

Read more

Coverage of a SharePoint 2010 project recently completed

Interesting coverage of a document repository system in SharePoint 2010 I recently implemented for a client based in Ireland.