我试图编写一个脚本来创建一个远程共享邮箱,但它无法工作。
以下错误显示当尝试转换它时。无法处理参数“类型”上的参数转换。由于枚举值无效,无法将“共享”值转换为"Microsoft.Exchange.Management.RecipientTasks.ConvertibleRemoteMailboxSubType“类型。指定下列枚举值之一,然后重试。可能的枚举值是“规则的、房间的、设备的”。
我们正在运行Exchange2010Hybird。
Connect-Hybrid
$SharedMailboxOU= "Shared Mailbox OU"
$SharedMailboxAccountOU = "Shared Mailbox Account OU"
$DisplayName=$mailboxName = Read-Host "Enter Mailbox Name"
$Alias = $mailboxName.replace(" ","_")
$GroupName = ("SM_" + $Alias)
$has_mailbox_found = Get-User $mailboxName -ErrorAction SilentlyContinue
if($has_mailbox_found){
Write-Host "Account already existed"
exit;
}else{
$group = New-DistributionGroup -Type Security -OrganizationalUnit $SharedMailboxOU -Name $GroupName
if($group) { Set-DistributionGroup $GroupName -HiddenFromAddressListsEnabled $true }
#$mailbox = New-RemoteMailbox -Name $DisplayName -Alias $Alias -OnPremisesOrganizationalUnit $SharedMailboxAccountOU
$password = ConvertTo-SecureString -String ("Password@@HHHSHSHSS") -AsPlainText -Force
$mailbox =New-RemoteMailbox -UserPrincipalName "$Alias@domain-co.uk" `
-DisplayName $Alias `
-Name $Alias
-OnPremisesOrganizationalUnit $SharedMailboxAccountOU `
-Alias $Alias `
-Password $password
if($group -and $mailbox) {
Add-MailboxPermission -Identity $Alias `
-User $GroupName -AccessRights FullAccess -InheritanceType All
Set-RemoteMailbox -Identity $Alias -Type Shared
$User_Identity = $mailbox.DistinguishedName
$User_Identity
#Move-ADObject -Identity $User_Identity -TargetPath $SharedMailboxAccountOU
}
}
发布于 2019-05-01 09:07:56
请注意Microsoft对共享类型的评论:
关于共有价值的说明:
共享仅在Exchange 2013 CU21或更高版本和Exchange 2016 CU10或更高版本中可用。要使用此值,还需要运行setup.exe /PrepareAD。有关更多信息,请参见KB4133605。 只能在最初在Exchange中创建的邮箱上使用Shared。如果邮箱最初是在就地Exchange中创建的,然后迁移到Exchange Online,则需要将邮箱迁移回就地Exchange,将邮箱转换为在现场Exchange中的共享邮箱,然后将共享邮箱迁移到联机Exchange。或者,您可以通过在Exchange服务器上运行以下命令,将Or邮箱的RemoteRecipientType属性值更改为"ProvisionMailbox、迁移、DeprovisionArchive“:server”-Replace @{msExchRemoteRecipientTYpe=“21}。
https://stackoverflow.com/questions/55933472
复制相似问题