Programmatically Change Sharepoint Web Application IP Address

Recently I was asked about changing a Sharepoint Web Application IP Addresses programatically, is this possible and how will it affect the Sharepoint sites?

I did some testing and it turns out that it is indeed possible to change the IIS Website IP Address without impacting the Sharepoint Web Application(s). For the most part Sharepoint does not care about the IP Address that are assigned to it's Web Application(s), what it cares about is how the IIS sites are mapped to it's Site Collections. The mapping is done via host header in IIS and Alternate Access Mappings in Sharepoint.

Hopefully there are no Sharepoint sites that are accessed using IP Addresses, if so when the IP Address changes, things will break.

Using  Host Headers and Alternate Access Mappings allow access via friendly names, these names are only bound by DNS so as

To create a friendly name like 'Portal' first I'll create a host header in IIS to my Sharepoint site, host headers allow me to have several IIS sites and only require one IP address.

In IIS select the Sharepoint site and click Bindings from the Actions menu, enter a friendly name, in my case 'Portal'

 Next Ill create a new A record on my DNS server so that the name Portal resolves to my Sharepoint Web Applications IP Address.

Next I'll create a Sharepoint Alternate Access Mapping so that Sharepoint knows what to do when it receives a request for this friendly name 'Portal'

Open Sharepoint Central Administration, select Application Management and under Web Applications select configure alternate access mappings.

Select the alternate access mapping collection for your site and select edit public URLs

Next add the url for your friendly name in one of the zone text boxes

After this configuration is complete Sharepoint can be accessed by typing http://portal. Next I want to programmatically change the IP address of my Sharepoint Web Application.

I found a Powershell script to perform this exact task.

$oldIp = ""
$newIp = ""

# Get all objects at IIS://Localhost/W3SVC
$iisObjects = new-object `

foreach($site in $iisObjects.psbase.Children)
    # Is object a website?
    if($site.psbase.SchemaClassName -eq "IIsWebServer")
    $siteID = $site.psbase.Name

    # Grab bindings and cast to array
    $bindings = [array]$site.psbase.Properties["ServerBindings"].Value

    $hasChanged = $false
    $c = 0

    foreach($binding in $bindings)
    # Only change if IP address is one we're interested in
    if($binding.IndexOf($oldIp) -gt -1)
    $newBinding = $binding.Replace($oldIp, $newIp)
    Write-Output "$siteID: $binding -> $newBinding"

    $bindings[$c] = $newBinding
    $hasChanged = $true

    # Only update if something changed
    $site.psbase.Properties["ServerBindings"].Value = $bindings

    # Comment out this line to simulate updates.

    Write-Output "Committed change for $siteID"
    Write-Output "========================="

Note: Remember DNS will have to be changed first to accommodate the IP Address change.

Provided there are multiple IP Addresses available on the Sharepoint server, this script will look for an old IP Address and update the IIS website to the new IP Address. Again Sharepoint does not care about the IP Address but it only cares about the request coming to it via IIS and matching the name with a Site Collection.

Hopefully this is helpful, it can be useful in fail over scenarios where re-iping at the fail over site is required.


  1. You are right we can change the IIS Website IP Address without impacting the Sharepoint Web Application. it is very right information and useful to all. now days sharepoint web application is very populer and your info. is very graceful on it as with coding.

    Hire Expert Sharepoint Application Web Developer

  2. Paul,
    I have question. We had a single installation server with WSS, TFS 2010 and SQL 2008. Unfortunately we were forced to change the IP address of the box (99). Now though we are able to access the sharepoint site and TFS site with new IP (90), both reporting services and the sharepoint dashboard are not coming. They are still pointing to the old IP address 99. I tried changing the IP in IIS, setting a redirecting DNS etc... but with no luck.

    Even when tried to create a new site... it started looking for 99. Then tried running configuration wizard removed the server from form and tried connecting again with new IP (90) though the SQL server was identified.... it failed with a note.. security exception could not connect to config database.

    Can you please advise further on this?