Quick Tip: Local Central Admin SPWebApplication

I’ve seen several incoming searches like “SPWebApplication for Central Admin”, so hopefully this will provide a quick answer:


Which really just returns:


And a quick example in PowerShell for good measure:

PS C:\> [system.reflection.assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null
PS C:\> $ca = [Microsoft.SharePoint.Administration.SPAdministrationWebApplication]::Local
PS C:\> $ca.DefaultServerComment
SharePoint Central Administration v3
PS C:\> $ca.AdministrativeTasks.Items | select Title -first 3

Add anti-virus protection
READ FIRST - Click this link for deployment instructions
Configure Workflow Settings

Hope this helps!

Finding an SPWebApplication by ID

Not sure if it was me that prompted Neil’s post, but a question that came up earlier today was how to retrieve an SPWebApplication from its ID. Neil suggested trying to retrieve the generic SPPersistedObject by that ID, which eventually led me to SPFarm.GetObject(Guid).

SPFarm farm = SPFarm.Local;
Guid webAppId = new Guid("e81de291-7205-42fe-8228-422c6bbed277");
SPWebApplication webApp = farm.GetObject(webAppId) as SPWebApplication;

Have I overlooked another method, or is this really the only way?

Bonus tip: Use SPAdministrationWebApplication.Local to get the web app for Central Admin.