非域计算机上的Set-ADComputer

时间:2018-09-11 08:27:58

标签: .net powershell active-directory

我想使用PowerShell从没有ActiveDirectory模块的干净计算机中添加AD中的扩展属性,因此我需要一个等效于Set-ADComputer的.Net。

示例:

Set-ADComputer -Identity My-Computer -Replace @{
    extensionAttribute1 = "MyAttribute"
}

1 个答案:

答案 0 :(得分:0)

$pc = "computername$"
$obj = ([adsisearcher]"samaccountname=$pc").FindOne().GetDirectoryEntry()
if($obj) {
    $obj.Put("extensionAttribute1", "myattribute")
    $obj.SetInfo()
}

另一个社区的帮助