RSS

outlook anywhere 启用后的配置脚本

29 Jan

脚本来自http://www.exchangeninjas.com/set-allvdirs,非常不错。Exchange 2007/2010均可使用。

# Script to allow you to set all virtual directories to a common name like mail.company.com
Start-Transcript
# Variables
[string]$UMExtend = "/UnifiedMessaging/Service.asmx"
[string]$OABExtend = "/OAB"
[string]$SCPExtend = "/Autodiscover/Autodiscover.xml"
[string]$EWSExtend = "/EWS/Exchange.asmx"
[string]$ConfirmPrompt = "Set this Value? (Y/N)"
[string]$NoChangeForeground = "white"
[string]$NoChangeBackground = "red"
Write-host "This will allow you to set the virtual directories associated with Autodiscover provided services to the name you provide."
Write-host ""
[string]$base = Read-host "Base name of virtual directory (e.g. mail.company.com)"
write-host ""
# =======================================================
# Validate if a third party trusted certificate is being used
# because BITS won't use untrusted certificates
[string]$set = Read-host "Is the certificate being used an internally generated certificate? (Y/N)"
Write-host ""
if ($set -eq "Y")    {
    [string]$OABprefix = "http://"
}    else    {
    [string]$OABprefix = "https://"
}
# =======================================================
# Build the Autodiscover URL and set the SCP Value
Write-host "Setting Autodiscover Service Connection Point" -foregroundcolor Yellow
write-host ""
$SCPURL = "https://" + $base + $SCPExtend
[array]$SCPCurrent = Get-ClientAccessServer
Foreach ($value in $SCPCurrent) {
    Write-host "Looking at Server: " $value.name
    Write-host "Current SCP value: " $value.AutoDiscoverServiceInternalUri.absoluteuri
    Write-host "New SCP Value:     " $SCPURL
    [string]$set = Read-host $ConfirmPrompt
    write-host ""
    
    if ($set -eq "Y")    {
         Set-ClientAccessServer -id $value.identity -AutoDiscoverServiceInternalUri $SCPURL
    }    else {
        write-host "Autodiscover Service Connection Point internal value NOT changed" -foregroundcolor $NoChangeForeground -backgroundcolor $NoChangeBackground
    }
}
# =======================================================
# Build the EWS URL and set the internal Value
Write-host "Setting Exchange Web Services Virtual Directories" -foregroundcolor Yellow
write-host ""
$EWSURL = "https://" + $base + $EWSExtend
[array]$EWSCurrent = Get-WebServicesVirtualDirectory
Foreach ($value in $EWSCurrent) {
    Write-host "Looking at Server: " $value.server
    Write-host "Current Internal Value: " $value.internalURL
    Write-host "New Internal Value:     " $EWSUrl
    [string]$set = Read-host $ConfirmPrompt
    write-host ""
    if ($set -eq "Y")    {
        Set-WebServicesVirtualDirectory -id $value.identity -InternalURL $EWSURL
     } else {
        write-host "Exchange Web Services Virtual Directory internal value NOT changed" -foregroundcolor $NoChangeForeground -backgroundcolor $NoChangeBackground
     }
    Write-host "Looking at Server: " $value.server
    Write-host "Current External Value: " $value.externalURL
    Write-host "New External Value:     " $EWSUrl
    [string]$set = Read-host $ConfirmPrompt
    write-host ""
    if ($set -eq "Y")    {
        Set-WebServicesVirtualDirectory -id $value.identity -ExternalURL $EWSURL
    } else {
        write-host "Exchange Web Services Virtual Directory external value NOT changed" -foregroundcolor $NoChangeForeground -backgroundcolor $NoChangeBackground
    }
}
# ======================================================
# Build the OAB URL and set the internal Value
Write-host "Setting OAB Virtual Directories" -foregroundcolor Yellow
write-host ""
$OABURL = $OABprefix + $base + $OABExtend
[array]$OABCurrent = Get-OABVirtualDirectory
Foreach ($value in $OABcurrent) {
    Write-host "Looking at Server: " $value.server
    Write-host "Current Internal Value: " $value.internalURL
    Write-host "New Internal Value:     " $OABUrl
    [string]$set = Read-host $ConfirmPrompt
    write-host ""
    if ($set -eq "Y")    {
        Set-OABVirtualDirectory -id $value.identity -InternalURL $OABURL
    } else {
        write-host "OAB Virtual Directory internal value NOT changed" -foregroundcolor $NoChangeForeground -backgroundcolor $NoChangeBackground
    }
    Write-host "Looking at Server: " $value.server
    Write-host "Current External Value: " $value.externalURL
    Write-host "New External Value:     " $OABUrl
    [string]$set = Read-host $ConfirmPrompt
    write-host ""
    if ($set -eq "Y") {
        Set-OABVirtualDirectory -id $value.identity -ExternalURL $OABURL
    } else {
        write-host "OAB Virtual Directory external value NOT changed" -foregroundcolor $NoChangeForeground -backgroundcolor $NoChangeBackground
    }
}
# =======================================================
# Build the UM URL and set the internal Value
Write-host "Setting UM Virtual Directories" -foregroundcolor Yellow
write-host ""
$UMURL = "https://" + $base + $UMExtend
[array]$UMCurrent = Get-UMVirtualDirectory
foreach ($value in $UMCurrent) {
    Write-host "Looking at Server: " $value.server
    Write-host "Current Internal Value: " $value.internalURL
    Write-host "New Internal Value:     " $UMUrl
    [string]$set = Read-host $ConfirmPrompt
    write-host ""
    if ($set -eq "Y") {
        Set-UMVirtualDirectory -id $value.identity -InternalURL $UMURL
    } else {
        write-host "UM Virtual Directory internal value NOT changed" -foregroundcolor $NoChangeForeground -backgroundcolor $NoChangeBackground
    }
    Write-host "Looking at Server: " $value.server
    Write-host "Current External Value: " $value.externalURL
    Write-host "New External Value:     " $UMUrl
    [string]$set = Read-host $ConfirmPrompt
    write-host ""
    if ($set -eq "Y") {
        Set-UMVirtualDirectory -id $value.identity -ExternalURL $UMURL
    } else {
        write-host "UM Virtual Directory external value NOT changed" -foregroundcolor $NoChangeForeground -backgroundcolor $NoChangeBackground
    }
}
Stop-Transcript

其中还包含了UM这块的配置,因为大部分其实不需要,下面是一个我的更新版本

# Script to allow you to set all virtual directories to a common name like mail.company.com

Start-Transcript

# Variables

[string]$OABExtend = "/OAB"
[string]$SCPExtend = "/Autodiscover/Autodiscover.xml"
[string]$EWSExtend = "/EWS/Exchange.asmx"
[string]$ConfirmPrompt = "Set this Value? (Y/N)"
[string]$NoChangeForeground = "white"
[string]$NoChangeBackground = "red"

Write-host "This will allow you to set the virtual directories associated with Autodiscover provided services to the name you provide."
Write-host ""
[string]$base = Read-host "Base name of virtual directory (e.g. mail.company.com)"
write-host ""
# =======================================================
# Validate if a third party trusted certificate is being used
# because BITS won't use untrusted certificates
[string]$set = Read-host "Is the certificate being used an internally generated certificate? (Y/N)"
Write-host ""

if ($set -eq "Y")    {
    [string]$OABprefix = "http://"
}    else    {
    [string]$OABprefix = "https://"
}

# =======================================================
# Build the Autodiscover URL and set the SCP Value

Write-host "Setting Autodiscover Service Connection Point" -foregroundcolor Yellow
write-host ""

$SCPURL = "https://" + $base + $SCPExtend

[array]$SCPCurrent = Get-ClientAccessServer

Foreach ($value in $SCPCurrent) {
    Write-host "Looking at Server: " $value.name
    Write-host "Current SCP value: " $value.AutoDiscoverServiceInternalUri.absoluteuri
    Write-host "New SCP Value:     " $SCPURL
    [string]$set = Read-host $ConfirmPrompt
    write-host ""
    
    if ($set -eq "Y")    {
         Set-ClientAccessServer -id $value.identity -AutoDiscoverServiceInternalUri $SCPURL
    }    else {
        write-host "Autodiscover Service Connection Point internal value NOT changed" -foregroundcolor $NoChangeForeground -backgroundcolor $NoChangeBackground
    }
}

# =======================================================
# Build the EWS URL and set the internal Value

Write-host "Setting Exchange Web Services Virtual Directories" -foregroundcolor Yellow
write-host ""

$EWSURL = "https://" + $base + $EWSExtend

[array]$EWSCurrent = Get-WebServicesVirtualDirectory

Foreach ($value in $EWSCurrent) {
    Write-host "Looking at Server: " $value.server
    Write-host "Current Internal Value: " $value.internalURL
    Write-host "New Internal Value:     " $EWSUrl
    [string]$set = Read-host $ConfirmPrompt
    write-host ""

    if ($set -eq "Y")    {
        Set-WebServicesVirtualDirectory -id $value.identity -InternalURL $EWSURL
     } else {
        write-host "Exchange Web Services Virtual Directory internal value NOT changed" -foregroundcolor $NoChangeForeground -backgroundcolor $NoChangeBackground
     }

    Write-host "Looking at Server: " $value.server
    Write-host "Current External Value: " $value.externalURL
    Write-host "New External Value:     " $EWSUrl
    [string]$set = Read-host $ConfirmPrompt
    write-host ""

    if ($set -eq "Y")    {
        Set-WebServicesVirtualDirectory -id $value.identity -ExternalURL $EWSURL
    } else {
        write-host "Exchange Web Services Virtual Directory external value NOT changed" -foregroundcolor $NoChangeForeground -backgroundcolor $NoChangeBackground
    }
}

# ======================================================
# Build the OAB URL and set the internal Value

Write-host "Setting OAB Virtual Directories" -foregroundcolor Yellow
write-host ""

$OABURL = $OABprefix + $base + $OABExtend

[array]$OABCurrent = Get-OABVirtualDirectory

Foreach ($value in $OABcurrent) {
    Write-host "Looking at Server: " $value.server
    Write-host "Current Internal Value: " $value.internalURL
    Write-host "New Internal Value:     " $OABUrl
    [string]$set = Read-host $ConfirmPrompt
    write-host ""

    if ($set -eq "Y")    {
        Set-OABVirtualDirectory -id $value.identity -InternalURL $OABURL
    } else {
        write-host "OAB Virtual Directory internal value NOT changed" -foregroundcolor $NoChangeForeground -backgroundcolor $NoChangeBackground
    }

    Write-host "Looking at Server: " $value.server
    Write-host "Current External Value: " $value.externalURL
    Write-host "New External Value:     " $OABUrl
    [string]$set = Read-host $ConfirmPrompt
    write-host ""

    if ($set -eq "Y") {
        Set-OABVirtualDirectory -id $value.identity -ExternalURL $OABURL
    } else {
        write-host "OAB Virtual Directory external value NOT changed" -foregroundcolor $NoChangeForeground -backgroundcolor $NoChangeBackground
    }
}


Stop-Transcript

Advertisements
 
Leave a comment

Posted by on January 29, 2010 in Exchange Server

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: