For quick reference: C# and PowerShell code snippets to grab the SharePoint central admin url for a farm.
Get central admin url with C#
SPAdministrationWebApplication webApp = SPAdministrationWebApplication.Local; string url = webApp.Sites.Url; Console.WriteLine(url);
You will need to add the following using statement:
…and with PowerShell
$webApp = [Microsoft.SharePoint.Administration.SPAdministrationWebApplication]::Local $webApp.Sites.Url
Each code snippet above will print the absolute url of SharePoint central admin.
I often find this handy within C# applications particularly. If you just want to open SharePoint central admin on the server and are not sure about the url, just search for “SharePoint central administration” from the start menu and open with the returned link.