Change SharePoint server hostname and Web Application Names

Note:

I realize that many admins are reluctant to delete web applications.  I personally know why I ma doing it and how to achieve this easily.  You should always retain any customization you have added to the site, like web.config mods, etc.  The Alternate Access Mappings are always available, but they leave open holes that I do not wish to keep active.  I like a clean setup.

Why?

Perhaps you need to clone a development, test, or some SharePoint server and you need to change the hostname so that it can exist on the same domain without a SID conflict.  Or you just have a use-case for wanting to rename the hostname of a SharePoint server.  It can be done, just make sure you go through all of the steps.

The Rename-SPServer PowerShell command can also be used to change the SQL Server name, for the case where you might move the databases to a new SQL server or instance and you need to point all of the farm servers to this new hostname\instance.

Changing the hostname isn't that bad, but it isn't enough as the web applications will revert back to the old name which is recorded in the configuration database and rests after a reboot.

Changing server hostname:

  1. Run the following command "Rename-SPServer" (Do not change the server hostname until after you run this command, or the farm will be unavailable until to revert the server back to its original name and rerun this command first)
  2. Rename-SPServer –Identity "wfb1" –Name "WFE1"  Technet Rename-SPServer
  3. Change the server hostname.  Then restart.
Now you should be able to login to Central Administration and see the web applications, but notice their URLs are still pointing to the old server names for any that are not using custom DNS names.

Changing Web Application URLs:

  1. Login to Central Admin.
  2. Navigate to Application Management -> Manage Web Applications
  3. For every site that is referencing the old server hostname in its URL, we will need to un-extend the web application from IIS.
  4. Note: You must do something special for the Central Admin site itself so I suggest you do this one last, as you will lost the ability to use Central Admin once you un-extend it.  (This requires PowerShell to extend it and get it back).
  5. Click on the web application.  Click the Delete drop-down menu in the Contribute section in the ribbon at top.
  6. Choose "Remove SharePoint from IIS web site" (This will remove the default zone for this web application so that you can go through the initial steps to provision the default site.  You may show two sites because of multiple zones, you may want to un-extend all of them, you just need to think through what you are doing)
  7. A window pops up.  Select the zone you wish to un-extend, it my case I needed to remove the default zone.  Delete IIS web sites = NO.  Click OK.
  8. In the same ribbon menu at top, click on Extend.  Go through the same motions you would to first create that default zone, except this time ensure the new hostname of the server is used in the URL.
  9. Repeat for all web applications until you are ready to do the Central Admin site.
  10. For Central Admin:  Repeat the same steps for un-extending the web application as you did for the others (there should only be one zone, Default).
  11. Now the Central Admin site is unusable, because you just removed the only zone you had to reference it.  Now we need to open PowerShell, either open the SharePoint Management Shell or run PowerShell ISE, just make sure that you open it "Run as Administrator" or the command will fail.
  12. If using straight PowerShell add the SharePoint Snapin:
    1. Add-PsSnapin Microsoft.SharePoint.PowerShell
  13. Run this command to extend the web application for Central Admin and get your GUI interface back (Change the names to suit your environment, it should be obvious what to change):
    1. Get-SPWebApplication -Identity http://spdev1:3333 | New-SPWebApplicationExtension –Name "Central Administration 3333" -HostHeader "" -Port 3333 -Zone "Default" -URL http://we_sharepoint

Afterthought:

You may want to change your central admin website to utilize SSL.  The above steps are very similar to how you would accomplish that.  Just make sure your DNS and SSL certificates are squared away or you will not have a Central Admin interface until you can route to the SSL site.  But you now know how to use PowerShell to get the Central Admin site back if it doesn't work the first time.

Comments

  1. Is this example is for SharePoint and SQL Server on the machine? what about SharePoint Application/WFE Server is a different machine?

    ReplyDelete
    Replies
    1. The example I detail above, I performed on a single machine with SQL server embedded. For a farm with separate servers the commands would be the same. You are writing to the configuration database. You may want to rename the index server, so the Rename-SPServer would apply in this case as well.

      Delete
  2. Deleting IIS site will make you loose all your customizations including web.config changes. So Don't do it!

    There is an easiest way to change SharePoint Web Application Port by updating IIS bindings and Alternate Access Mappings from here: How to Change Sharepoint Web Application Port

    ReplyDelete
    Replies
    1. I never go with the easy solution. I have never been a fan of AAM. But deleting a site is easy and I do it often, but I know why I wish to do so. I encourage every admin to research and test any action before performing live. In fact you should be deleting and recreating web applications in a dev or test environment to understand what is happening. This should also encourage admins to backup their IIS areas.

      Delete

Post a Comment

Popular posts from this blog

SharePoint Designer 2013 Approval Workflow with Comments

SharePoint Search - Content Processing Pipeline Failed to Process the Item