2

this must be possible via PowerShell as it can be done from Central Administration. I have a task to modify just the public URL of an existing alternate access mapping (AAM).

PS U:\> $aam = Get-SPAlternateURL -WebApplication http://mysite
PS U:\> $aam

IncomingUrl             Zone            PublicUrl
-----------             ----            ---------
http://default.mysite   Default         http://default.mysite
http://mysite           Internet        http://mysite

So with the above AAM, in the Internet zone, I need to change the public URL to say http://othermysite

If I run

PS U:\> Set-SPAlternateURL -Identity http://mysite -Zone Internet -Url http://othermysite

I end up with both the public URL and Internal URL changed

PS U:\> $aam = Get-SPAlternateURL -WebApplication http://othermysite
PS U:\> $aam

IncomingUrl             Zone            PublicUrl
-----------             ----            ---------
http://default.mysite   Default         http://default.mysite
http://othermysite      Internet        http://othermysite

As well, Set-SPAlternateURL does not provide an argument -Internal like the New-SPAlternateURL cmdlet.

If I run

PS U:\> New-SPAlternateURL -WebApplication http://default.mysite -Zone Internet -Url http://mysite -Internal

I get the correct aam, but I have two in the list of Internet zone aam now.

PS U:\> $aam = Get-SPAlternateURL -WebApplication http://default.mysite
PS U:\> $aam

IncomingUrl             Zone            PublicUrl
-----------             ----            ---------
http://default.mysite   Default         http://default.mysite
http://othermysite      Internet        http://othermysite
http://mysite       Internet        http://othermysite

If I try to remove the aam

http://othermysite      Internet        http://othermysite

both aam for the Internet zone are removed.

So how can I get the following accomplished via PowerShell, or is this only possible via the GUI in Central Administration?

IncomingUrl             Zone            PublicUrl
-----------             ----            ---------
http://default.mysite   Default         http://default.mysite
http://mysite       Internet        http://othermysite
2

You need to do this in three steps as the IncomingURL and PublicURL are equal. Start by removing what you have on the internet zone (1) and build your url-structure starting with the PublicURL (2). When that's done - set a new URL for the IncomingURL (3).

#(1)
Remove-SPAlternateURL -WebApplication http://mysite -Zone "Internet"

#(2)
New-SPAlternateURL http://othermysite -Zone "Internet"

#(3)
New-SPAlternateURL http://mysite -Zone "Internet" -internal

Now you have what you wish for:

IncomingUrl             Zone            PublicUrl
-----------             ----            ---------
http://mysite           Internet        http://othermysite

From this setting, you are able to set the publicURL since it differs from the IncomingURL:

Get-SPAlternateURL “http://othermysite” | Set-SPAlternateURL “http://newothermysite”

And the outcome will be

IncomingUrl             Zone            PublicUrl
-----------             ----            ---------
http://mysite           Internet        http://newothermysite

Reference: Remove-SPAlternateUrl, New-SPAlternateUrl and Managing SharePoint 2013 with PowerShell: Working with Alternate Access Mappings

0

You accidentally wrote "-Zone Internet" in your command. That should be the problem.

The command you need should be this:

PS U:\> New-SPAlternateURL -Url http://mysite -WebApplication http://default.mysite -Zone Default -Internal

Here is an Link to a googlebook where you can find more information how to create AAM's(Chapter 5.7)

  • I think he wanted to change the Internet Zone mapping! – Robert Lindgren Oct 2 '13 at 13:23
  • It wasn't an accident, that's the scenario – nickytonline Oct 3 '13 at 0:37
  • Sorry my fault. – ReTech Oct 7 '13 at 10:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.