在另一个域(PowerShell)中的计算机阵列上设置ADComputer ExtesionAttribute1

在另一个域(PowerShell)中的计算机阵列上设置ADComputer ExtesionAttribute1,powershell,dns,Powershell,Dns,如何在另一个域中的计算机阵列上使用PowerShell设置ADComputer ExtensionAttribute1?您很可能需要远程域的凭据,并运行Set-ADComputer,其中-Server指向该域中的域控制器: $Credentials = Get-Credential $Computers = Get-Content c:\ListOfComputers.txt foreach ($Computer in $Computers) { Set-ADComputer -Identit

如何在另一个域中的计算机阵列上使用
PowerShell
设置ADComputer ExtensionAttribute1?

您很可能需要远程域的凭据,并运行Set-ADComputer,其中-Server指向该域中的域控制器:

$Credentials = Get-Credential
$Computers = Get-Content c:\ListOfComputers.txt

foreach ($Computer in $Computers)
{
Set-ADComputer -Identity $Computer -Credential $Credentials -Server RemoteDC -Add @{extensionAttribute1="myString"}
}

我在一个有13个域的环境中工作,所以这是我遇到的一件非常常见的事情。。。格伦上面所解释的将是完成这项任务的正确方法。您将在变量中存储远程域的凭据,然后在每台计算机中循环,并发出set-adcomputer cmdlet以更改属性。如果您有很多服务器,我建议您使用作业来发布set cmdlet。

两位贡献者(Mathias R.Jessen和Glen Buktenica)都解决了我的问题。 我把命令分成两半都没有用。 当我在Set ADComputer函数调用中添加-Server参数时。更改反映在正确的计算机和正确的域中

Set-ADComputer -identity "$server" -Server "$DNS_Host_Name" -replace @{ExtensionAttribute1 = "$changeIt"}
我试了几十次。
谢谢你帮助我。你们真是太棒了!TGIF

使用
-Server
参数以其他域中的DC为目标您是否有您已经尝试过的示例@MathiasR.Jessen是正确的,但如果我们能向您展示如何在特定脚本中实现,那将是最简单的。Set-ADComputer-标识“$server”-服务器“$DNS_Host_Name”-替换@{ExtensionAttribute1=“$changeIt”}谢谢您,MathiasGlen,我绝对需要-凭据吗?我现在正在测试这个。我相信是你的帮助促成了这一切。等待“变化”发生