Home > PowerShell, SharePoint, SharePoint 2010 > How to get the Central Administration URL using PowerShell

How to get the Central Administration URL using PowerShell


I have seen several posts on how to get the Central Administration URL using PowerShell either obtained from the Registry or using PowerShell CommandLets however I didn’t really want to use the Registry, and the other approaches returned a PSCustomObject rather than a string. I needed a string so that this can be used as the URL for the site collection to open a TaxonomySession to automate the import of managed metadata into a term store before my new site collection was actually created. Here are some of the approaches that I found.

First approach using the Registry:

Get-ItemProperty -Path ‘HKLM:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\WSS\’ -Name CentralAdministrationURL | select CentralAdministrationURL;

Second approach finds Central Administration by name (not ideal as this could be changed), and returns a PSCustomObject:

Get-SPWebApplication -includecentraladministration | where {$_.DisplayName -eq "SharePoint Central Administration v4"} | Select Url

Third approach does not require the name but still returns a PSCustomObject:

Get-SPWebApplication -includecentraladministration | where {$_.IsAdministrationWebApplication} | select Url

The final approach returns a string which was just what I needed:

Get-SPWebApplication -includecentraladministration | where {$_.IsAdministrationWebApplication} | Select-Object -ExpandProperty Url

Instead of using “Select Url”, “Select-Object -ExpandProperty Url” returns the value as its native type, a string.

Advertisements
  1. Pushkar
    January 9, 2014 at 06:20

    Thank you so much, works like a charm

  2. EwanoE
    May 20, 2014 at 08:08

    [Microsoft.SharePoint.Administration.SPAdministrationWebApplication]::Local.Url

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: