在项目过程中会遇到需要同时设置很多台Exchange Server服务器的虚拟目录URL,图形界面设置比较麻烦。可以使用Powershell命令一下搞定。下面以设置Exchange 2013为例,其他版本的Exchange稍微修改脚本内容即可:
脚本内容如下:
1、OWA URL
检查设置是否存在问题,通过添加-whatif参数预先执行以下命令而不实际修改具体配置
foreach($servers in (Get-OwaVirtualDirectory | where{$_.owaversion -eq "Exchange2013"})){Get-OwaVirtualDirectory -Server $servers.server | Set-OwaVirtualDirectory -InternalUrl "" -ExternalUrl "" -whatif}更改配置,运行下面命令将对服务器配置进行实际更改
foreach($servers in (Get-OwaVirtualDirectory | where{$_.owaversion -eq "Exchange2013"})){Get-OwaVirtualDirectory -Server $servers.server | Set-OwaVirtualDirectory -InternalUrl "" -ExternalUrl ""}
2、ECP URL
检查设置是否存在问题,通过添加-whatif参数预先执行以下命令而不实际修改具体配置
foreach($servers in (Get-OwaVirtualDirectory | where{$_.owaversion -eq "Exchange2013"})){Get-ecpVirtualDirectory -Server $servers.server | Set-ecpVirtualDirectory -InternalUrl "" -ExternalUrl "" -whatif}
更改配置,运行下面命令将对服务器配置进行实际更改
foreach($servers in (Get-OwaVirtualDirectory | where{$_.owaversion -eq "Exchange2013"})){Get-ecpVirtualDirectory -Server $servers.server | Set-ecpVirtualDirectory -InternalUrl "" -ExternalUrl ""}
3、EWS URL
检查设置是否存在问题,通过添加-whatif参数预先执行以下命令而不实际修改具体配置
foreach($servers in (Get-OwaVirtualDirectory | where{$_.owaversion -eq "Exchange2013"})){Get-WebServicesVirtualDirectory -Server $servers.server | Set-WebServicesVirtualDirectory -InternalUrl "" -ExternalUrl "" -whatif}更改配置,运行下面命令将对服务器配置进行实际更改
foreach($servers in (Get-OwaVirtualDirectory | where{$_.owaversion -eq "Exchange2013"})){Get-WebServicesVirtualDirectory -Server $servers.server | Set-WebServicesVirtualDirectory -InternalUrl "" -ExternalUrl ""}
4、OAB URL
检查设置是否存在问题,通过添加-whatif参数预先执行以下命令而不实际修改具体配置
foreach($servers in (Get-OwaVirtualDirectory | where{$_.owaversion -eq "Exchange2013"})){Get-OabVirtualDirectory -Server $servers.server | Set-OabVirtualDirectory -InternalUrl "" -ExternalUrl "" -whatif}更改配置,运行下面命令将对服务器配置进行实际更改
foreach($servers in (Get-OwaVirtualDirectory | where{$_.owaversion -eq "Exchange2013"})){Get-OabVirtualDirectory -Server $servers.server | Set-OabVirtualDirectory -InternalUrl "" -ExternalUrl ""}
5、Powershell URL
检查设置是否存在问题,通过添加-whatif参数预先执行以下命令而不实际修改具体配置
foreach($servers in (Get-OwaVirtualDirectory | where{$_.owaversion -eq "Exchange2013"})){Get-PowerShellVirtualDirectory -Server $servers.server | Set-PowerShellVirtualDirectory -InternalUrl "" -ExternalUrl "" -whatif}更改配置,运行下面命令将对服务器配置进行实际更改
foreach($servers in (Get-OwaVirtualDirectory | where{$_.owaversion -eq "Exchange2013"})){Get-PowerShellVirtualDirectory -Server $servers.server | Set-PowerShellVirtualDirectory -InternalUrl "" -ExternalUrl ""}
6、ActiveSyncVirtualDirectory URL
检查设置是否存在问题,通过添加-whatif参数预先执行以下命令而不实际修改具体配置
foreach($servers in (Get-OwaVirtualDirectory | where{$_.owaversion -eq "Exchange2013"})){Get-ActiveSyncVirtualDirectory -Server $servers.server | Set-ActiveSyncVirtualDirectory -InternalUrl "" -ExternalUrl "" -whatif}更改配置,运行下面命令将对服务器配置进行实际更改
foreach($servers in (Get-OwaVirtualDirectory | where{$_.owaversion -eq "Exchange2013"})){Get-ActiveSyncVirtualDirectory -Server $servers.server | Set-ActiveSyncVirtualDirectory -InternalUrl "" -ExternalUrl ""}