Carol
Carol

Reputation: 67

How to retrieve all the Web Application URLs using WSS object model

I was able to retrieve all the web application names within a farm using object model. But I could not find a way to display all the web application URLs within a farm.

Can some one help me with this?

Upvotes: 1

Views: 2447

Answers (3)

x0n
x0n

Reputation: 52450

I take it you probably really want all site collection URLs on all web applications. Here's a short powershell script I wrote - you should be able to infer the C# OM from this:

[reflection.assembly]::loadwithpartialname("microsoft.sharepoint") > $null

[Microsoft.SharePoint.Administration.SPFarm]::local.services | `
    where-object {$_ -is [Microsoft.SharePoint.Administration.SPWebService] } | `
    select -expand webapplications | select -expand sites | `
    select url, zone, owner, rootweb | format-table -auto

Hope this helps,

-Oisin

Upvotes: 1

Colin
Colin

Reputation: 10638

The webapplication urls are bound to the Zones used by the webapplication (i.e. the Default, Internet and Intranet zones), find them using the SPWebApplication.AlternateUrls property. (msdn)

Upvotes: 1

Related Questions