Sytone's Ramblings

The occasional posts of a guy who plays with technology.

Getting the Central Admin URL for a Farm in SharePoint

2010-07-30 1 min read Technology

Toy Car I recently needed to get the Url of the CA for a SharePoint farm, after a bit of hunting in the API it was tracked down under the SPAdministrationWebApplication object.

C#

[code lang=“csharp”] SPAdministrationWebApplication caWebApp = Microsoft.SharePoint.Administration.SPAdministrationWebApplication.Local; var url = caWebApp.Sites[0].Url; [/code]

PowerShell

[code lang=“ps”] $caWebApp = [Microsoft.SharePoint.Administration.SPAdministrationWebApplication]::Local $caWebApp.Sites[0].Url [/code]