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