Exchange 2010 Powershell指令碼攻略(十四)
enable-FederatedDeliveryMailbox
$ErrorActionPreference = "SilentlyContinue"
# check syntax
if (!$args -or ($args.Length -ne 3 -and $args.Length -ne 1))
{
write-host "You need to run this script after you have configured Federated Delivery using New/Set-OrganizationRelationship task. This script needs to be run at both tenant side and on-premise side.";
write-host "Tenant side: enable-FederatedDeliveryMailbox.ps1
write-host "OnPremise side: enable-FederatedDeliveryMailbox.ps1
exit
}
$isDataCenter = $args.Length -eq 3
if ($isDataCenter)
{
write-host "Running on Data Center"
$organizationFederatedMailbox = $(Get-TransportConfig -Identity $args[2]).OrganizationFederatedMailbox
# OrganizationFederatedMailbox must be set.
if ( ($organizationFederatedMailbox -eq $null) -or (!$organizationFederatedMailbox.IsValidAddress) )
{
write-host "Transport Settings must have OrganizationFederatedMailbox set."
exit
}
$mailboxId = $args[2] + "" + $organizationFederatedMailbox.ToString()
write-host "Searching for existing Federated Delivery Mailbox with identity" $mailboxId
$error.Clear()
$mailbox = Get-Mailbox -Arbitration -Identity:$mailboxId;
if ($error.Count -gt 0)
{
write-host "Failed to read mailbox information" $error[0].Exception;
exit;
}
else
{
$error.Clear();
$organizationFederatedMailboxLiveId = $mailbox.WindowsLiveID
if ( ($organizationFederatedMailboxLiveId -eq $null) -or (!$organizationFederatedMailboxLiveId.IsValidAddress) )
{
write-host "Federated Delivery Mailbox is not Live enabled. Creating LiveID for Federated Delivery Mailbox" $organizationFederatedMailbox.ToString()
$pwd = (ConvertTo-SecureString $args[1] -AsPlainText -Force)
$mailbox = Set-Mailbox -Arbitration -Identity $mailboxId -WindowsLiveId:$organizationFederatedMailbox.ToString() -Password $pwd -Force
if ($error.Count -gt 0)
{
write-host "Failed to Live enable Federated Delivery Mailbox because of " $error[0].Exception;
exit;
}
else
{
write-host "Successfully Live enabled Federated Delivery Mailbox";
}
}
else
{
write-host "Federated Delivery Mailbox already Live enabled."
}
}
}
else
{
write-host "Running in on-premise setup"
$organizationFederatedMailbox = $(Get-TransportConfig).OrganizationFederatedMailbox
# OrganizationFederatedMailbox must be set.
if ( ($organizationFederatedMailbox -eq $null) -or (!$organizationFederatedMailbox.IsValidAddress) )
{
write-host "Transport Settings must have OrganizationFederatedMailbox set."
exit
}
}
# Get the organization relationship setting based on organization relationship identity passed in as parameter.
$organizationRelationship = Get-OrganizationRelationship -Identity:$args[0];
if ($organizationRelationship -eq $null)
{
write-host "There is no organization relationship based on the identity" $args[0]
exit
}
# Provision the remote domain setting for this org.
write-host "Provisoning Remote Domains ........"
$remoteDomains = $null
if ($isDataCenter)
{
$remoteDomains = Get-RemoteDomain -Organization $args[2]
}
else
{
$remoteDomains = Get-RemoteDomain
}
foreach ($domain in $organizationRelationship.DomainNames)
{
$domainName = $domain.ToString()
$foundMatch = $false
# Go through existing remote domains to find match with organization relationship domains
foreach ($remoteDomain in $remoteDomains)
{
$match = $remoteDomain.DomainName.match($domainName)
if ($match -gt 0)
{
# For the one that matches (more than wild card matching, i.e. matching to *), we should set the following properties to make cross premise mail look like internal.
write-host "Remote domain" $remoteDomain.Name "with domain" $remoteDomain.domainname.address "matches organization relationship domain" $domainName
$foundMatch = $true
$remoteDomain | Set-RemoteDomain -AllowedOOFType InternalLegacy -AutoForwardEnabled $true -AutoReplyEnabled $true -TNEFEnabled $true
}
}
if ($foundMatch -eq $false)
{
# Create new remote domain entry and prep for cross premise federated delivery.
write-host "Creating a new remote domain for" $domainName
$newRemoteDomain = $null
if ($isDataCenter)
{
$newRemoteDomain = New-RemoteDomain -Name $domainName -DomainName $domainName -Organization $args[2]
}
else
{
$newRemoteDomain = New-RemoteDomain -Name $domainName -DomainName $domainName
}
$newRemoteDomain | Set-RemoteDomain -AllowedOOFType InternalLegacy -AutoForwardEnabled $true -AutoReplyEnabled $true -TNEFEnabled $true
}
}
[@more@]來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23700676/viewspace-1052340/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Exchange 2010 Powershell指令碼攻略(十五)指令碼
- Exchange 2010 Powershell指令碼攻略(十三)指令碼
- Exchange 2010 Powershell指令碼攻略(十二)指令碼
- Exchange 2010 Powershell指令碼攻略(十一)指令碼
- Exchange 2010 Powershell指令碼攻略(十)指令碼
- Exchange 2010 Powershell指令碼攻略(九)指令碼
- Exchange 2010 Powershell指令碼攻略(八)指令碼
- Exchange 2010 Powershell指令碼攻略(七)指令碼
- Exchange 2010 Powershell指令碼攻略(六)指令碼
- Exchange 2010 Powershell指令碼攻略(五)指令碼
- Exchange 2010 Powershell指令碼攻略(四)指令碼
- Exchange 2010 Powershell指令碼攻略(三)指令碼
- Exchange 2010 Powershell指令碼攻略(二)指令碼
- Exchange 2010 Powershell指令碼攻略(一)指令碼
- powershell指令碼指令碼
- PowerShell 指令碼中的密碼指令碼密碼
- PowerShell 指令碼執行策略指令碼
- powershell重新命名指令碼指令碼
- Exchange 2010搭建
- Bash指令碼debug攻略指令碼
- 開機自啟動Powershell指令碼指令碼
- linux shell 指令碼攻略筆記Linux指令碼筆記
- 【黑客基礎】Windows PowerShell 指令碼學習(上)黑客Windows指令碼
- 最簡單的一個powershell的指令碼指令碼
- Exchange 2010需要的網路埠
- 微軟宣佈全新命令列+指令碼工具:PowerShell 7微軟命令列指令碼
- 五個實用的SQL Server PowerShell指令碼OMSQLServer指令碼
- 利用powershell指令碼Windows hosts記錄替換IP指令碼Windows
- Win10使用Powershell提示禁止執行指令碼怎麼辦 Win10使用Powershell提示禁止執行指令碼如何解決Win10指令碼
- shell指令碼攻略--DNS正向解析一鍵部署指令碼DNS
- 利用 Powershell 編寫簡單的瀏覽器指令碼瀏覽器指令碼
- 【連結】LINUX SHELL指令碼攻略筆記[速查]Linux指令碼筆記
- 《Linux Shell指令碼攻略(第2版)》書評Linux指令碼
- nuget打包檔案丟失如何使用powershell指令碼解決指令碼
- 使用VSCode遠端除錯惡意Powershell指令碼VSCode除錯指令碼
- 【VMware VCF】使用 PowerShell 指令碼管理 SDDC Manager 中的軟體包。指令碼
- PowerShell 指令碼來監控 CPU、記憶體和磁碟使用情況:指令碼記憶體
- linux shell 指令碼攻略學習6-xargs詳解Linux指令碼