Skip to content

Update a web application URL and IIS bindings for SharePoint

 Update a web application URL and IIS bindings for SharePoint 

A quick Google search gave me this but below is just another way to make it easier using power shell with less clicking. This applies to SharePoint 2010, 2013 and 2016.  

https://technet.microsoft.com/en-us/library/cc262366.aspx  

Scenario:

Let’s say you created a web application http://danger for your users and they are working on it and site is live, all good. One fine morning site owner decided this name is not good and want to change the URL to something else like http://ranger

You can change URL from Central Administration and in case you don’t want to click too much you can use the 4 liner PowerShell at the end of this write.

Using Central Administration:  

Extend the web application to a zone that is not used yet. Let’s say “Custom” zone. 

You can enter any host header value for example “tempsite” as this will be temporary extension of web app with any port number, we will get rid of this zone once done.  

Once web application is extended, you can confirm that by going to Alternate Access Mapping page, you will see a new mapping http://tempsite in zone you used while extending.

Go back to Manage Web Application page high light web application http://danger by clicking on it and click on tiny drop down on the Delete button in the ribbon. Select “Remove SharePoint from IIS Web Site”, Select zone from the drop down with unwanted URL in this case its “danger”, check box for delete IIS web site and click ok.  

So far, we have removed the unwanted URL and move everything over to a new URL called tempsite. Go back and extend the web application again and this time enter the correct URL http://ranger , port 80 and make sure you select Default zone from the drop down. Hit ok. Once done check your site with new URL, in this case http://ranger .  

You can remove the custom Zone URL as mentioned earlier using “Remove SharePoint from IIS Site” option.

Using Power Shell

Add-PSSnapin Microsoft.sharepoint.powershell 
$Auth=New-SPAuthenticationProvider
Get-SPWebApplication -Identity http://danger | New-SPWebApplicationExtension -Name TempSite -Zone Custom -Port 80 -HostHeader TempSite -Url http://tempsite -AuthenticationMethod NTLM -AuthenticationProvider $Auth 

Get-SPWebApplication -Identity http://danger | Remove-SPWebApplication -Zone Default -DeleteIISSite -Confirm:$false  

Get-SPWebApplication -Identity http://danger | New-SPWebApplicationExtension -Name Ranger -Zone Default -Port 80 -HostHeader sandy -Url http://ranger -AuthenticationMethod NTLM -AuthenticationProvider $Auth -Confirm:$false 

Get-SPWebApplication -Identity http://ranger
| Remove-SPWebApplication -Zone Custom -DeleteIISSite -Confirm:$false

Change the parameters as per your requirements. If you want you can add “sleep –seconds 5” after each command for IIS web site to be crated on each server, but it all depends how big environment is. 

Update Web Application Name 

Above command will update the URL but notice web application name is still the same “SharePoint –Danger”. To change Web Application name, use the following script.

$WApp= Get-SPWebApplication -Identity http://ranger  
$WApp.Name=”SharePoint – Ranger” 
$WApp.Update() 

Get-SPWebApplication 

 HTH

This operation can be performed only on a computer that is joined to a server farm by users ……..

Error Message: This operation can be performed only on a computer that is joined to a server farm by users who have permissions in SQL Server to read from the configuration database. To connect this server to the server farm, use the SharePoint Products Configuration Wizard, located on the Start menu in Microsoft SharePoint 2010 Products.

Issue Description:
In one of my SharePoint environment I start getting this error when browse site collection, it was working fine until yesterday. As per the error message I check all the permission for all the accounts on all databases including config database but no luck.

After several reboots, IIS resets and Googling, back to Event viewer I came across this warning mentioned below from source: ASP.NET. This warning at least has account name. I made sure that account specified in this warning has all the permissions needed but no luck.

Warning in Event Viewer: Event ID: 1309, Source: ASP.NET, Level: Warning
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 6/26/2017 3:11:03 PM
Event time (UTC): 6/26/2017 7:11:03 PM
Event ID: 1f56666ca7d249979903cbb7c1aa15de
Event sequence: 2
Event occurrence: 1
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/1927342608/ROOT-3-131429778631987995
Trust level: Full
Application Virtual Path: /
Application Path: C:\inetpub\wwwroot\wss\VirtualDirectories\Contoso Home-80\
Machine name: ContosoMachine
Process information:
Process ID: 13012
Process name: w3wp.exe
Account name: DOMAIN\\AccountName
Exception information:
Exception type: InvalidOperationException
Exception message: This operation can be performed only on a computer that is joined to a server farm by users who have permissions in SQL Server to read from the configuration database. To connect this server to the server farm, use the SharePoint Products Configuration Wizard, located on the Start menu in Microsoft SharePoint 2016  Products.
at Microsoft.SharePoint.Utilities.SPUtility.AlternateServerUrlFromHttpRequestUrl(Uri url)
at Microsoft.SharePoint.Administration.SPAlternateUrl.GetContextUri(HttpContext ctx)
at Microsoft.SharePoint.SPAppRequestContext.InitCurrent(HttpContext context)
at Microsoft.SharePoint.SPAppRequestContext.get_Current()

Solution:
If all steps mentioned above did not work for you try one more, Go to Central Administration > Security > Configure Managed Accounts> Edit the account mentioned in the warning> in my case it was app pool account  > check Change Password now > select the option Use Existing Password> enter the password and click OK. That’s it. 

If  your issue resolved feel free to leave a comment or let me know if any other solution. 

 

 

 

Send email to all users in SharePoint group

Last week I was asked if it’s possible to send email to all SharePoint Group Members. Quick solution I tried was to select all users and click “Email Users” Under “Actions” menu in SharePoint user group. I t will select only user that are on the page not on the next page. You will see an arrow (pagination) to go to next page in case you have more than 30 users.
Item limit any for SharePoint users Group is set to 30 by default. You can increase it to whatever you want. But let’s say if you have 500 users in a group called “Members” you can set the view limit to 99 but “Email Users” under “Actions” menu will not work anymore. You can try. It will throw error something like “cannot send email to that number of users “
Of course there are more than one way to achieve this goal, below is one I came up with quickly and though will share.
Copy and paste each line individually after changing the URL with your site collection url.

$Site=Get-SPSite http://SiteCollectionURL
$Site.rootweb
($Site.rootweb).groups
($Site.rootweb).groups | Format-table -Property name, owner
           # in my case I wanted to send email to all users in “Approvers” group
($Site.rootweb).groups[“Approvers”]
($Site.rootweb).groups[“Approvers”].users | Format-Table -Property DisplayName, Email
($Site.rootweb).groups[“Approvers”].users | Format-Table -Property Email >email.txt

You can modify the script and make it short, by adding more variables but this gave me what I was looking for. Wonder how this will work if one has thousands of users in a group. I don’t have any group with that big number so can’t test, if you have that big group let us know. Might have to use –LimitAll in command.

Another way to do this is open up excel click on data connections and add a new web data connection. Enter URL of the SharePoint group and it will ask you to enter your SPGroupUserslcredentials and will open up group view in excel where you can export every ting from the page in to Excel. Some formatting is needed here but you can easily get user first name and last name and then using formulas convert these 2 column in email address. Let me know if need more info on this option and I will post in detail.