Connecting custom service application proxies using Powershell

In my current project we have scripted a NewsGator install in a multi-server farm. One of the challenges we faced is that we needed to connect a proxy for the NewsGator Social Platform Services service application. This is very straight forward for the out-of-the-box service applications in SharePoint, as each have specific Powershell cmdlets:


For custom service applications it’s a little bit more complicated. By the way, I most cases you need to set up a trust relationship between the servers before trying to connect the proxy. This also applies to the out-of-the box proxies. The next step is to get the connection URI for the service application. You can use the topology web service for that:

$connectionUri = (Receive-SPServiceApplicationConnectionInfo `

Next, loop through all the service proxies to find the right proxy type. Notice that we need to look at each service proxy through the eyes of the IServiceProxyAdministration interface to get access to the GetProxyTypes method.

foreach($sp in (Get-SPFarm).ServiceProxies)
    $spa = $sp -as `
    $types = $spa.GetProxyTypes()
    $type = $types | ? { $_.FullName –eq $ProxyTypeName }
    if ($type –ne $null) { break }


Finally, create and provision the proxy:

[Microsoft.SharePoint.Administration.SPServiceProvisioningContext] `
    $provisioningContext = $null
$serviceApplicationProxy = $serviceProxyAdministration.CreateProxy( `
    $type, "NG Proxy", $connectionUri, $provisioningContext)

(Using null for the provisioning context parameter seems to work fine, so I didn’t spend more time trying to figure out what that value should be.)

You can now verify that the service proxy is available in Central Administration | Manage service applications.

NOTICE! To make this post more readable all error handling has been removed from the scripts.

Comments (0)