Remove multiple bindings in IIS 7 - iis

I'm hosting about 100 sites in IIS. I'm moving to a new ip range. While I've added the new ip addresses manually ( it took some time) I would like to avoid removing the old ip's manually. I have already removed the old ip's from the network. Is there a powershell command that would allow me to remove bindings for all sites containing a specific ip address?

You have a list of IP addresses and you would like to remove each one from bindings in IIS?
If so, put the list of IP address(one per line) in a text file, ie. IPs.txt, open powershell, cd to the directory where IPs.txt sits and run the following:
Import-Module WebAdministration
cat .\IPs.txt | % { Get-WebBinding -IPAddress $_ | Remove-WebBinding -Confirm:$true}
You will have to confirm each delete but this is most likely preferable to deleting an incorrect binding, ie. if you have an empty line line in the file it will return ALL bindings..

I would look at using the Web Server (IIS) Administration Cmdlets in Windows PowerShell
There's some awesome functionality available for doing what you're after.
Example:
Get-WebBinding -IPAddress "192.168.*" | Remove-WebBinding -WhatIf
This example selects all web bindings on the local machine that matches the ip address (including wildcard) then pipes the results to the Remove-WebBinding cmdlet. Obviously you'd need to set the criteria up for your own scenario. Remove the -WhatIf switch only when you're sure you've selected the bindings you're interested in and are ready to do it (!)
You may have been able to have used the Set-WebBinding command that also exists in this module to just update the original ones.
Hope that helped.

Related

What could be the possible reasons if nslookup command for a domain is not showing correct records?

I am not able to access one of my website from office which is hosted in Microsoft azure. When i have tried to lookup for dns lookup.
I is not showing me the correct ip address or showing some thing like mydomainname.kkph.com.
While i can access the same website from other devices around the world.
I have also checked with Godaddy support team but didn't find any issue at their end.
First, you could ensure that you have a correct IP address binds with your website and have a mapping A or CNAME record in your DNS domain provider.
For this issue, you could check the followings:
DNS cache on the local office machine. Use ipconfig/flushdns to clear it.
DNS Suffix Search List. You could check if you have a DNS suffix automatically appended to your hostname when you query. You could check it via 'ipconfig/all' or find the box Append parent suffixes of the primary DNS suffix and DNS Suffix Search List under the Advanced TCP/IP Settings---DNS. Also, to avoid using the search list, always use a Fully Qualified Domain Name (that is, add the trailing dot to the name) when you run nslookup fqdn. Read here.
Try to nslookup on another machine from the office to find if there is something wrong with a specific machine.
If no luck, please show the result of nslookup for further help. I would like to suggest to capture the netmon traces on your local environment.

Unable to create reachable host-name site collection in SharePoint

These are the commands i ran Administrator Windows Power Shell to create a host-name site collection to a existing web application
powershell -version 2
Add-PsSnapin Microsoft.SharePoint.PowerShell
New-SPSite http://www.test5.sp/ -OwnerAlias MyDomain\administrator -HostHeaderWebApplication http://Mywebapplication/
In this point i see a new site collection created under Mywebapplication in central admin.
I added a new record to hosts file:
127.0.0.1 test5.sp
And i get ping for test5.sp
I edited the bindings of iis and added a new binding:
Type|Host Name|Port|Ip Address
http|test5.sp |80 |127.0.0.1
And then ran
iisreset /noforce
In this point the test5.sp is not accessible from the browser.
Can you please help?
I managed to access the host name site collection that i created after the following changes:
I changed the iis bindings to be:
Type|Host Name|Port|Ip Address
http|test5.sp |80 |*
For some reason (that i don't really understand) there is a problem to access the host name site collection from a machine that the SharePoint is installed on.
So i added the test5.sp to the host files on another machine:
[The ip address of the webapplication] test5.sp
This solved the problem :)

IIS Virtual Directory Map to different URL

So on a normal machine (i.e. not a server) running Win 8.1 I have this virtual directory on the DefaultWebSite, to get to it I type in Google http://localhost/MyCoolSite.
Now, I want to map that to http://mycoolsite.com or something similar - just not have it accessed via http://localhost/MyCoolSite.
You need to make IIS rewrite rule for mapping / to /MyCoolSite URLs. The second item you need to take care of resolving the mycoolsite.com hostname. For this you need to simply update the C:\Windows\System32\drivers\etc\host with your local IP with hostname. Like,
127.0.0.1 mycoolsite.com

Host website on new gTLD?

With the new gTLDs being opened up (let's use .example as an example) is it possible to host a website at http://example ? Or does there still need to be a 2nd level (e.g. http://something.example)?
Thanks
It's technically possible, but some people may have problems because some systems treat a host name without any dots in it as being a local name instead of a DNS name.
Indeed, a few smaller ccTLDs already have A records at their apex.
It wont be possible.. even for brand gTLD.
.example --> TLD
you need domain.example to set an host

Add a *new* DestinationBinding for a site to a package using MSDeploy

I'm using a staging model with MSDeploy to deploy a couple of our sites to a web farm. The sites are configured in IIS on the staging boxes only, and then MSDeploy is used to build the target web servers from scratch.
The staging box uses its own bindings (ie no header entries, different IPs/ports and no host headers) for the sites that will be live. When I deploy them I first have an xml file used to prepare a parameterised package (using the -declareParamFile switch) which declares parameters as follows:
<parameters>
<parameter name="site1">
<parameterEntry kind="DestinationBinding" scope="Site1" match=":17000:" />
</parameter>
</parameters>
So in the above XML you can see that the staged site is hosted on port 17000 as the match attribute is set to match a binding that has that value.
When I then deploy to each live site, I use a different parameters XML that specifies the correct host header and IP for that machine - I apply this using the -setParamFile switch. Here's an example of one of them.
<parameters>
<setParameter name="site1" value="[ip_addr]:[port]:[host_header]"/>
</parameters>
So, because the original parameter is declared to match one of the known bindings - I can replace that binding with what I actually want it to be on each live server.
What I want to do now is to deploy the site and add new destination bindings to it that incorporate the different TLDs that we have - i.e. site.com, site.co.uk, site.ca etc, all bound on the same IP address and port.
The reasons for wanting to do this are:
We have a new site that we want to deploy that will need a different hostname, but we don't want to give it it's own IP address (running out of IPs here!) but have it share the IP that an existing site on the servers already has.
This means adding specific hostname bindings to the site that's already on there, instead of having it respond to any hostname.
We have four domain names currently pointing to the existing site's load balanced IP(.com, .us, .ca, .com.au). At the moment it works because the web server doesn't care about the host header - but when the new site goes on the same IP, it will, and the other domain names will no longer work.
The problem is I don't think there appears to be any way of adding such information. I've tried adding multiple setParameter elements in the second XML, but that simply has the effect of repeatedly overwriting the binding, with the last one as the eventual winner.
One solution is for me to add 'placeholder' bindings for each of the sites on the staging box, which represent the target external bindings for each domain name, port etc; and then I modify the two parameters files to replace those bindings with the real ones.
But to me this feels completely wrong - that would be modelling the staging box to suit the live deployment; it should be the other way around.
Is it possible to actually add site bindings with MSDeploy (if so, how?), or does it only support replacement?
After much head-banging, it appears that there is no way to add new bindings using the DestinationBinding operation with msdeploy.
What would be possible would be to attach a script to be executed after deployment that adds the bindings using appcmd every time.
So, the initial synchronisation via msdeploy would remove those bindings (because they're not on the staging server) but the appcmd script would then add them again.
Not really an ideal solution, though, as it's yet another script that has to be kept up to date.

Resources