【问题标题】:Set-ADComputer on non domain computer非域计算机上的 Set-ADComputer
【发布时间】:2019-02-15 17:07:20
【问题描述】:

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

例子:

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

【问题讨论】:

  • Set-ADComputer 允许使用显式凭据进行连接 (Set-ADComputer -Server -Credential。不过,您需要先安装 RSAT 并激活 AD PowerShell 模块。
  • 如果您想避免安装 RSAT,您需要使用相应的 .Net 方法/对象。请做一些研究并尝试提出一些代码。 SO 不是免费的脚本编写服务。
  • 如果您有适当的权限,您可以使用“Enter-PSSession -ComputerName myComputer”连接到安装了 RSAT 或域控制器的远程计算机并在那里运行您的脚本/命令.

标签: .net powershell active-directory


【解决方案1】:
$pc = "computername$"
$obj = ([adsisearcher]"samaccountname=$pc").FindOne().GetDirectoryEntry()
if($obj) {
    $obj.Put("extensionAttribute1", "myattribute")
    $obj.SetInfo()
}

另一个社区帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-09
    • 2018-11-02
    相关资源
    最近更新 更多