How to fix the error "Value does not fall within expected range" from SRS Integration with SharePoint

I have written a tool that will help you fix the following error you can receive from Central Administration->Application Management->Reporting Services (section header)->Set Server Defaults. This tool is only meant to fix the error when you receive it from this location. If you receive this error when clicking on a report or other Reporting Services item in a Document Library this is caused when the report item location and the URL you are accessing the SharePoint site by differ. To resolve that issue you will need to either delete and redeploy your reports, change the public URL of the site back to what it was when you deployed the reports or access the SharePoint site using the same URL you used when you deployed the report.

The error from "Set Server Defaults" will usually look like this:

System.Web.Services.Protocols.SoapException: An internal error occurred on the
report server. See the error log for more details. ---> Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An
internal error occurred on the report server. See the error log for more details.
---> System.ArgumentException: Value does not fall within the expected range
."

Cause:

This is can be caused by the following things:

1. You have more than one WFE that has the Central Administration role and the server that currently has that role is not the first one in the list of Central Admin servers.

2. You have moved the Central Administration URL (different port etc) after it was created.

Resolution:

1. Give only one server in the farm the Central Administration role rather than multiple. This alone may not resolve the issue since the Central Administration URL might not be removed correctly from the SharePoint database object. If it does not use the resolution for #2 below.

2. Use the tool attached to this blog post. The instructions on how to use it are included in the .zip file.

SharePointTool.zip