Error while trying to connect to a published Service Application in SharePoint 2010: “Unable to connect to the specified address. Verify the URL you entered and contact the service administrator for more details.”

When you receive this error

Unable to connect to the specified address. Verify the URL you entered and contact the service administrator for more details.

…and you have done the exchange of farm certificates than you forgot this step:

$consumingFarmID=<Farm GUID of the consuming farm>

$security=Get-SPTopologyServiceApplication | Get-SPServiceApplicationSecurity

$claimprovider=(Get-SPClaimProvider System).ClaimProvider

$principal=New-SPClaimsPrincipal -ClaimType "http://schemas.microsoft.com/sharepoint/2009/08/claims/farmid" -ClaimProvider $claimprovider -ClaimValue $consumingFarmID

Grant-SPObjectSecurity -Identity $security -Principal $principal -Rights "Full Control"

Get-SPTopologyServiceApplication | Set-SPServiceApplicationSecurity -ObjectSecurity $security

(Technet: http://technet.microsoft.com/en-us/library/ff700211.aspx)

See the first line of the script:

$consumingFarmID=<Farm GUID of the consuming farm>

→ Here you need to execute this PowerShell code snippet and insert the resulting GUID in the script above:

(Get-SPFarm).Id 

OCSetup and DISM: Component Names

If you want to install windows features by script you have to use one of the tool OCSETUP oder DISM.

E.g.
start /w ocsetup <component_name>
or
dism /online /enable-feature:<component_name>

BUT: What are the “component names” for the Windows features? First of all: These “component names” are technical names, not the “display names” you will find in Control Panel -> Turn Windows features on or off

You can get a list of the available features if DISM tool is available:

dism /online /get-features

BTW: The component names are case-sensitive!!! – E.g. the component name “NetFx3” (for “Microsoft .Net Framework 3.x”) is not the same as “netfx3”.

But sometimes the technical feature names are very diffrent from the display names. For example: “IIS-LegacySnapIn” is the name for this “IIS 6 Management Console”



Here you’ll find complete lists for the mapping of display name and technical component name

“Passphrase” error while creating a new SharePoint 2010 farm with PowerShell cmdlet “New-SPConfigurationDatabase”

I tried to create a new SharePoint Server 2010 farm by using PowerShell cmdlet “New-SPConfigurationDatabase” in one of the first steps.

I got this error:

New-SPConfigurationDatabase : The passphrase supplied does not meet the minimum complexity requirements. Please select another passphrase that meets all of the following criteria: is at least 8 characters; contains at least three of the following four character groups: English uppercase characters (A through Z); English lowercase characters (a through z); Numerals (0 through 9); Non-alphabetic characters (such as !, $, #, %). Type a passphrase which meets these requirements.

At C:UsersService.SP_InstallDesktopSetupScript.ps1:41 char:28
+ New-SPConfigurationDatabase <<<< -DatabaseName $spconfigdbname -DatabaseServer $dbserver -Passphrase $sppassphrase_sec -FarmCredentials $spfarmcredential
+ CategoryInfo : InvalidArgument: (System.Security.SecureString:SecureString) [New-SPConfigurationDatabase], SPException
+ FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletNewSPConfigurationDatabase

This is my script:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

$sppassphrase=“GOY$sV3SthlkyN%3YTdS&”
$sppassphrase_sec = (ConvertTo-SecureString $sppassphrase -AsPlainText -force)

$spfarmuser=“domainfarmaccount”
$spfarmuserpwd=“P@ssw0rd”

#Securing Settings
$spfarmcredential = new-object -typename System.Management.Automation.PSCredential -argumentlist $spfarmuser, (ConvertTo-SecureString $spfarmuserpwd -AsPlainText -force)

New-SPConfigurationDatabaseDatabaseName “configdb” -DatabaseServer “sqlserver” -Passphrase $sppassphrase_sec -FarmCredentials $spfarmcredential

After debugging I found the following:

When I write the value of variable “$sppassphrase” the the console (with cmdlet write-host) I get:
GOY%3YTdS&
instead of
GOY$sV3SthlkyN%3YTdS&

The problem is: The part “$sV3SthlkyN” will be interpreted as variable name!!!

You have to use escape sequences at least for the “$” character:

$sppassphrase=“GOY`$sV3SthlkyN%3YTdS&”

UPDATE!

Use ‘ instead of ” and you will not have a problem at all!

$sppassphrase=‘GOY$sV3SthlkyN%3YTdS&’

You’ll get what you’ve expected: The correct password string including “$”… (But the solution above also works!)

Project Server 2010: Error Message “Could not retrieve enterprise global template. Please contact your administrator.”

 

After renaming my SharePoint 2010 from an old to a new URL I could not longer access any project from this server.

The error message looked like this:

“Could not retrieve enterprise global template. Please contact your administrator.”

I could solve the problem by removing the existing Project Server Account connections in the registry:

HKEY_CURRENT_USERSoftwareMicrosoftOffice14.0MS ProjectProfiles<[1..n] project server connections as sub keys>

Before that I copied the URL from the “Path” value under the registry key.

Then I recreated the Project Server Account by using Microsoft Project’s tool.

 

Please notice my disclaimer in the right sidebar!

FileNotFoundException while developing an external SharePoint application

If you develop a SharePoint Application with Visual Studio 2010, e.g. a Console Aplication, you may get an FileNotFoundException.

For example in this code (program.cs):

namespace DemoConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
           SPSite site = new SPSite("http://sharepoint.local");  //<<--- FileNotFoundException
           SPWeb web = site.RootWeb;
           //your code here

        }
    }
}

I’ve maked the line of code where you may receive the exception.

I solved the problem by setting the platform target in the project settings: Go to “project settings”, select “Build” tab, set “Platform target” setting to the architecture of your platform. I always use “x64” there. – After that the exception is gone.

Activate Claim Based Authentication afterwards with PowerShell

You can active Claim Based Authentication for a SharePoint Web App afterwards if you missed that at creation time.

Use this PowerShell script:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
[System.Reflection.Assembly]::LoadFile($Env:CommonProgramFiles+"Microsoft SharedWeb Server Extensions14ISAPIMicrosoft.SharePoint.dll") | out-null

$webapp = Get-SPWebApplication "http://<sharepoint server>/"
write-host "Current: " $webapp.UseClaimsAuthentication
$webapp.UseClaimsAuthentication = $true
$webapp.Update()

$webapp.ProvisionGlobally()

write-host "    New: " $webapp.UseClaimsAuthentication

Enable CollectSPRequestAllocationCallStacks with PowerShell

I got this message in the ULS log:

An SPRequest object was not disposed before the end of this thread. To avoid wasting system resources, dispose of this object or its parent (such as an SPSite or SPWeb) as soon as you are done using it.  This object will now be disposed.  Allocation Id: {646667A7-73BC-4DDD-B0FB-6EDFC315CCE7}  To determine where this object was allocated, set Microsoft.SharePoint.Administration.SPWebService.ContentService.CollectSPRequestAllocationCallStacks = true. 

The following PowerShell script will do that for me – and you 🙂

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
[System.Reflection.Assembly]::LoadFile($Env:CommonProgramFiles+"Microsoft SharedWeb Server Extensions14ISAPIMicrosoft.SharePoint.dll") | out-null

# Get Content Service of the farm
$contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService

# Display and change the setting of property "CollectSPRequestAllocationCallStacks"
write-host "Current: " $contentService.CollectSPRequestAllocationCallStacks 
$contentService.CollectSPRequestAllocationCallStacks = $true
$contentService.Update()

write-host "    New: " $contentService.CollectSPRequestAllocationCallStacks 

Add web.config Modification with PowerShell (SPWebConfigModification)

Here is a script I used to add some web.config modifications with PowerShell. In this case I want to add a custom authentication provider. – The following script I used for setup purpose.

# Load SharePoint PowerShell PSSnapIn and the main SharePoint .net library
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$sharePointDLL = $ENV:CommonProgramFiles+("Microsoft SharedWeb Server Extensions14ISAPIMicrosoft.SharePoint.dll")
[System.Reflection.Assembly]::LoadFile($sharePointDLL) | out-null

# Show Farm BuildVersion to ensure the SharePoint .net library is loaded
$localFarm = [Microsoft.SharePoint.Administration.SPFarm]::Local
$localFarm.BuildVersion

# store some settings and objects in variables
$webapp = [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup($url)
$farmServices = @($webapp.Farm.Services | where-object { $_.TypeName -eq "Microsoft SharePoint Foundation Web Application" } )[0]
$assembly = "MyAuthenticationProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxx"

# Remove old web.config modifications of MyAuthenticationProvider
$oldMods = @();
$webapp.WebConfigModifications | where-object { $_.Owner -eq "MyAuthenticationProvider" } | foreach-object { $oldMods = $oldMods + $_}

$oldMods | foreach-object{ $webapp.WebConfigModifications.Remove($_) }

# update the Web Application and apply all existing web.config modifications - this executes the "remove" actions from above
$webapp.Update()
$farmServices.ApplyWebConfigModifications()

# New web.config modifications for MyAuthenticationProvider
$myModification1 = new-object "Microsoft.SharePoint.Administration.SPWebConfigModification"
$myModification1.Path = "configuration/system.web/membership/providers"
$myModification1.Name = "add[@name='MyAuthenticationProvider'][@type='MyAuthenticationProvider.MyMembershipProvider, " + $assembly + "']"
$myModification1.Sequence = 0
$myModification1.Owner = "MyAuthenticationProvider"
$myModification1.Type = 0           #for the enum value "SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode"
$myModification1.Value = "<add name='MyAuthenticationProvider' type='MyAuthenticationProvider.MyMembershipProvider, " + $assembly + "' />"
$webapp.WebConfigModifications.Add($myModification1)

$myModification2 = new-object "Microsoft.SharePoint.Administration.SPWebConfigModification"
$myModification2.Path = "configuration/system.web/roleManager/providers"
$myModification2.Name = "add[@name='MyAuthenticationProvider'][@type='MyAuthenticationProvider.MyRoleProvider, " + $assembly + "']"
$myModification2.Sequence = 0
$myModification2.Owner = "MyAuthenticationProvider"
$myModification2.Type = 0           #for the enum value "SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode"
$myModification2.Value = "<add name='MyAuthenticationProvider' type'MyAuthenticationProvider.MyRoleProvider, " + $assembly + "' />"
$webapp.WebConfigModifications.Add($myModification2)

# Update the Web Application and apply all exisiting web.config modifications including the new from above

$webapp.Update()
$farmServices.ApplyWebConfigModifications()

Please notice my disclaimer in the right sidebar!

“TaxonomyPicker” failed to load – Error in Event Viewer

After updating the SharePoint Foundation 2010 Server of our company to SharePoint Server 2010 I got this error in the Event Viewer:

Load control template file /_controltemplates/TaxonomyPicker.ascx failed: 
Could not load type 'Microsoft.SharePoint.Portal.WebControls.TaxonomyPicker' 
from assembly 'Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.

I could solve this error by re-enabling the corresponding feature using this PowerShell script:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
[System.Reflection.Assembly]::LoadFile($Env:CommonProgramFiles+"Microsoft SharedWeb Server Extensions14ISAPIMicrosoft.SharePoint.dll") | out-null
Get-SPWebApplication -IncludeCentralAdministration | get-spsite | foreach-object { enable-spfeature "73ef14b1-13a9-416b-a9b5-ececa2b0604c" -force -url $_.Url -Verbose }

Note: The first to lines of the script enable are “standard lines of code” for me. They enable SharePoint PowerShell support if you use the Script without “SharePoint 2010 Management Shell”.

How To Activate SharePoint Ribbon Tab by JavaScript Code

In the last weeks I’ve extended the sample project that I’ve created for “Ribbon Customization”. You find the project source code on Codeplex:

The related articles on my blog are:


There are lots of excellent articles out there about SharePoint 2010 Ribbon customization.

Some articles that helped me:

Especially the first blog post in the above list leaves a question open: "Using client-side code to show ribbon items".

I had the same problem: How to activate a custom SharePoint Ribbon tab by JavaScript code?

After some reading in SharePoint standard JavaScript files I found the solution. I used some jQuery too:

1: $(document).ready(function  () {

 

2:     ExecuteOrDelayUntilScriptLoaded(salesappActiveRibbonTab, "sp.ribbon.js" );

 

3:

 

4:     function  salesappActiveRibbonTab() {

 

5:         try  {

 

6:             _ribbonStartInit("MyApp.SharePoint.Ribbon.CustomTab" , false , null );

 

7:         } catch  (e) {

 

8:         };

 

9:     };

 

10: });

This allows me to activate my custom Ribbon tab with ID "MyApp.SharePoint.Ribbon.CustomTab" by JavaScript code. It works pretty fine!

Update 1

Meanwhile I created an test project for adding a custom ribbon tab while runtime. There I have had the problem, that the ribbon was created correctly BUT was not activated thru the code above. After some debugging of MS Ribbon JavaScript I created the following code:

var ribbontestintervall = null;

 

function RibbonTestActiveRibbonTab2() {     try {         window.clearInterval(ribbontestintervall);

 

        if (typeof (_ribbonStartInit) == "function")             _ribbonStartInit('RibbonTest.SharePoint.Ribbon.CustomTab', false, null);

 

        if (true && typeof (_ribbonReadyForInit) == 'function' && !_ribbonReadyForInit()) {             ribbontestintervall = window.setInterval("RibbonTestActiveRibbonTab2()", 1000);         }     } catch (e2) {     };
};

So the Browser retries the activation of the tab as long as it works.

Update 2 (2011/01/14)

See my new post and sample project on CodePlex :

Sample Visual Studio 2010 project for creating a custom SharePoint 2010 Ribbon tab on runtime (!)

Update 3 (2011/03/03)

Next part posted today. See the part list at the top of this blog post.