How do you check if a web application extension already exist
-
08-10-2020 - |
Question
I can create a new web application extension using New-SPWebApplicationExtension
but if it already exist I get an error with the message "The IIS Web Site you have selected is in use by SharePoint. You must select another port or hostname.".
I tried using Get-SPWebApplication
but it does not return the extensions. I know I could catch the thrown exception and react on it but I wonder if there is a more cleaver way, e.g. Get-SPWebApplicationExtension
that I can use to check if it already exist?
Solution
You have to use the Get-SPAlternateURL
, it will return url from all zone then you will be know if one you are requesting being used or not
The Get-SPAlternateURL cmdlet returns all alternate URLs that match the scope given by either the optional Identity parameter or by a combination of the optional WebApplication, Zone, or Resource parameters. Each criterion that is added narrows the scope. If no criteria are specified then all alternate URLs are returned.