Поделиться через


Script to configure static ports on Exchange Server 2010

There is nothing new about this. If you have been reading about Exchange Server 2010 or have it deployed with hardware load balancer, chances are, you have read how to configure static ports on Exchange Server 2010 on TechNet Social wiki for Exchange 2010. Chances are that you have also used my script (referenced in the post above) to set static ports on your servers. Lastly, chances are that you have read all about it on my previous post here.

If so, why am I even talking about it today?

Well, if you haven’t noticed a few things already, the way you change ports is different in RTM and SP1. My script didn’t account for SP1 originally when it was written. Was SP1 even existed then?

The other reason is my nature of always learning something and making things better! I noticed how my code was inefficient now that I know a few more things about PowerShell (yeah that’s not funny). I decided to write it more efficiently and that basically meant a complete overhaul of my old script.

The new script is now more user friendly! It uses cmdletbinding and comment based help. It means, for you as a user, you can just type:

 Get-Help Set-StaticPorts.ps1 –examples

or

 Get-Help Set-StaticPorts.ps1 –Full

The script now validates parameters using ValidateRange and ValidateScript. I think that’s cool! It also uses 59531 and 59532 by default now. How about using recommended ports instead of random ones I used in my previous script? I think that’s even more cool!

The script uses all the right write-* cmdlets now instead of write-host. So now you can use tee-object and won’t end up with empty output file. Yes you loose cool colors I used with write-host but hey, you are trying to set ports on your Exchange Server 2010. For colors you would go see Macy’s Fireworks on New Year, right? Smile

Oh and last but probably the most important change is inclusion of –auto and –whatif functionality!

-WhatIf is obvious. Script will tell you what it is doing without actually making any changes.

-Auto will automatically find all your Exchange 2010 CAS servers and Exchange 2010 Mailbox servers that are hosting Public Folders. It will then change ports on CAS Server for RPC CA service and Exchange AB service. On Mailbox servers it will only change RPC CA ports as Exchange AB service doesn’t exist on Mailbox only role.

If you combine all this with –Force, you can also silence the script. It won’t ask you for any confirmation and will change ports you specify (or use defaults) and restart the services! Isn’t that awesome!

So go download the script from here: Set-StaticPorts.ps1 and give it a go. As always, let me know if you find any issues and I will be happy to fix it.

Comments

  • Anonymous
    January 01, 2003
    Nauman, Which other ports are they listening on? THey shouldn't be listening on other ports after the change and service restart. Thanks, Bhargav

  • Anonymous
    January 01, 2003
    Josh, You’re getting this error because you don’t have Exchange cmdlets loaded. Please ensure you have Exchange cmdlets loaded either by initiating remote session or starting Exchange Management Shell before running the script. You can’t run it from plain PowerShell window. Thanks, Bhargav

  • Anonymous
    December 05, 2011
    Having trouble getting this to work.. PS C:UsersjbadminDesktop> .rpcstaticports.ps1 -Server rgxxentexmb02 Get-Command : The term 'Get-ExchangeServer' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the n ame, or if a path was included, verify that the path is correct and try again. At C:UsersjbadminDesktoprpcstaticports.ps1:85 char:13

  •     Get-Command <<<<  Get-ExchangeServer | Out-Null    + CategoryInfo          : ObjectNotFound: (Get-ExchangeServer:String) [Get   -Command], CommandNotFoundException    + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Co   mmands.GetCommandCommand The term 'Get-ExchangeServer' is not recognized as the name of a cmdlet, functi on, script file, or operable program. Check the spelling of the name, or if a p ath was included, verify that the path is correct and try again. At C:UsersjbadminDesktoprpcstaticports.ps1:342 char:24
  • If ((Get-ExchangeServer <<<<  $server).AdminDisplayVersion -match "Version 14 ")    + CategoryInfo          : ObjectNotFound: (Get-ExchangeServer:String) [],   CommandNotFoundException    + FullyQualifiedErrorId : CommandNotFoundException Any ideas?
  • Anonymous
    January 29, 2013
    Hi Bhargav, I did a "Netstat -nab" which showed the RCP CA and the Address Book services listening on the specified static ports but I see that they were also listening on some other ports. Is that normal and OK? Or does it mean something hasn't been configured correctly? Thanks.