Set-ADGroup -Identity "St.Department.146" -Replace @{"msExchRequireAuthToSendTo"=$true} -verbose输入命令时发生错误。:(
Set-ADGroup :在行:1 char:1处指定了无效的dn语法
ActiveDirectoryCmdlet:System.ArgumentException,
发布于 2020-12-03 07:41:13
从错误中
已指定无效的dn语法
显然,由于标识参数,错误正在发生。
您可以尝试以下几种方法:
Set-ADGroup -Identity "CN=St.Department.146,OU=Mail Group,OU=STKGroup,DC=doublethink,DC=me" -Replace @{"msExchRequireAuthToSendTo"=$true} -verbose如果要避免任何错误,可以执行get组,然后将其传递到下一步:
$InternalDistro = (Get-ADGroup -filter 'name -eq "St.Department.146"')
Write-Host $InternalDistro[0].DistinguishedName
Set-ADGroup -Identity $InternalDistro[0].DistinguishedName -Replace @{"msExchRequireAuthToSendTo"=$true} -verbose确保屏幕中有一个输出,其中包含所需的DN。
发布于 2020-12-03 13:35:00
若要避免Identity参数中的错误,请尝试使用Get-ADGroup查找组作为对象。如果成功,则将组对象通过管道传输到Set-ADGroup。
Get-ADGroup返回一个具有默认属性DistinguishedName、GroupCategory、GroupScope、Name、ObjectClass、ObjectGUID、SamAccountName、SID的对象。
# try and find the group with that name.
# Use double-quotes around the filter and single-quotes around the name itself.
$groupName = 'St.Department.146'
# instead of property Name, you can also try property DisplayName here
$group = Get-ADGroup -Filter "Name -eq '$groupName'" -ErrorAction SilentlyContinue
if ($group) {
$group | Set-ADGroup -Replace @{msExchRequireAuthToSendTo = $true} -Verbose
}
else {
Write-Warning "A group with name '$groupName' does not exist"
}在这种情况下,很可能是这个组的名称与其DisplayName不同。在上面的代码中,如果您看到组不存在的警告消息,请更改
-Filter "Name -eq '$groupName'"转换为-Filter "DisplayName -eq '$groupName'",并尝试一下。
https://stackoverflow.com/questions/65102444
复制相似问题