我想使用PowerShell在没有ActiveDirectory模块的干净计算机中添加AD中的扩展属性,所以我需要.Net等效于Set-ADComputer
。
例:
Set-ADComputer -Identity My-Computer -Replace @{
extensionAttribute1 = "MyAttribute"
}
$pc = "computername$"
$obj = ([adsisearcher]"samaccountname=$pc").FindOne().GetDirectoryEntry()
if($obj) {
$obj.Put("extensionAttribute1", "myattribute")
$obj.SetInfo()
}
另一个社区帮助