在PowerShell中使用全局编录 [英] Using a global catalog in PowerShell
问题描述
我在目录林中有多个域,并且我试图编写一个可以与目录林中的任何用户一起使用的脚本,因此我在脚本中使用了全局目录。
I have multiple domains in my forest, and I'm trying to write a script that will work with any user in the forest, so I'm using a global catalog in my script.
这可以检索数据,但是当我尝试修改数据时,我会得到
This works to retrieve the data, but when I try and modify the data I'm getting
Set-ADUser:服务器不愿意处理请求
Set-ADUser : The server is unwilling to process the request
如果我使用域控制器(DC)作为服务器名称,修改将按预期完成。我想避免编写用于设置服务器名称的开关。我还能在这里做什么?
If I use the domain controller (DC) as the server name, the modification completes as it should. I'd like to avoid writing a switch to set the server name. Is there anything else I can do here?
Get-ADUser $user -Server "contoso.local:3268" | %{Set-ADUser -Identity $_.distinguishedname -SamAccountName $_.SamAccountName -Server "contoso.local:3268"}
推荐答案
我不清楚您要在此处做什么。全局编录端口是只读的(对于LDAP)。
I'm not really clear on what you're trying to do here. Global catalog ports are read only (for LDAP).
如果要确保找到作为全局编录的域控制器,可以使用以下命令: / p>
If you want to make sure you find a domain controller that is a global catalog, you can use the following:
Get-ADDomainController -Discover -Service GlobalCatalog
根据您的评论,也许您需要的是 $ PSDefaultParameterValues
:
$PSDefaultParameterValues = @{
"*-AD*:Server" = "contoso.local:3268"
}
Get-ADUser $user |
%{Set-ADUser -Identity $_.distinguishedname -SamAccountName $_.SamAccountName }
这篇关于在PowerShell中使用全局编录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!