尝试运行一个看似简单的 Set-Group 命令,但失败了,我不知道为什么。在 Set-Group Technet 页面中,它显示以下内容...
要添加或删除所有者而不影响其他现有条目,请使用以下语法:@{Add="owner1","owner2"...; Remove="owner3","owner4"...}。
但是运行下面的程序时失败了......
set-group -Identity "O365Group" -ManagedBy @{Add="User1","User2"}
由于此错误而失败...
无法处理参数“ManagedBy”的参数转换。无法将值“System.Collections.Hashtable”转换为类型“Microsoft.Exchange.Configuration.Tasks.GeneralRecipientIdParameter[]”。错误:“无法将值“System.Collections.Hashtable”转换为类型“Microsoft.Exchange.Configuration.Tasks.GeneralRecipientIdParameter”。错误:“无法将哈希表转换为以下类型的对象:Microsoft.Exchange.Configuration.Tasks.GeneralRecipientIdParameter。受限语言模式或数据部分不支持哈希表到对象的转换。””+ CategoryInfo : InvalidData: (:) [Set-Group],ParameterBindin... mationException + FullyQualifiedErrorId : ParameterArgumentTransformationError,Set-Group + PSComputerName : outlook.office365.com
知道为什么会失败吗?
答案1
如果这是 Office 365 组,您可能需要使用 *-unifiedgrouplinks 命令行。
#note to add an owner, they have to be a member first
Add-UnifiedGroupLinks -Identity [email protected] -LinkType Member -Links [email protected]
Add-UnifiedGroupLinks -Identity [email protected] -LinkType Owner -Links [email protected]
Remove-UnifiedGroupLinks -Identity [email protected] -LinkType Owner -Links [email protected]
所以如果我想添加[电子邮件保护],[电子邮件保护],[电子邮件保护]作为所有者[电子邮件保护]我将从 Exchange Online Powershell 会话运行以下命令
"[email protected]","[email protected]","[email protected]"|%{
Add-UnifiedGroupLinks -Identity [email protected] -LinkType Member -Links $_
Add-UnifiedGroupLinks -Identity [email protected] -LinkType Owner -Links $_
#If you want to subscribe them as well, uncomment this line
#Add-UnifiedGroupLinks -Identity [email protected] -LinkType subscriber -Links $_
}
关于这些命令行开关的更多信息可以在这里找到:
删除统一组链接:https://technet.microsoft.com/en-us/library/mt238271(v=exchg.160).aspx
添加 UnifiedGroupLinks:https://technet.microsoft.com/en-us/library/mt238269(v=exchg.160).aspx
获取统一组链接:https://technet.microsoft.com/en-us/library/mt238273(v=exchg.160).aspx
答案2
不要使用Set-Group
,Set-DistributionGroup
而要使用 。
Set-DistributionGroup -Identity "O365Group" -ManagedBy @{Add="User1","User2"}
我已经在我们的 Office 365 部署上测试了这一点,虽然Set-Group
失败了,但Set-DistributionGroup
仍然正常运行。