【问题标题】:Copy AD attributes (state to city) in a specific OU在特定 OU 中复制 AD 属性(州到城市)
【发布时间】:2019-03-07 17:21:34
【问题描述】:

我对一个简单的脚本有疑问。我需要复制 OU 中所有用户的属性(STATE 到 CITY)。我找到了这个脚本,但是某处有错误。

有人可以帮我解决这个问题吗?

Get-ADUser -Filter * -SearchBase "MY OU" -Properties city, state |
    ForEach-Object {
        Set-ADObject -Identity $_.DistinguishedName ` -Replace @{city=$($_.state)}
    }

【问题讨论】:

  • “但某处有错误” “错误”究竟是什么意思?你有错误吗?它说什么?它发生在哪里?

标签: powershell active-directory attributes ou


【解决方案1】:

获取 state 有值的所有用户的命令(避免尝试使用 Replace 不接受的空值的预防措施)并将该值写入城市属性 (L)

PS> Get-ADUser -SearchBase "ou=test accounts,dc=domain,dc=ccTLD" -LDAPFilter '(st=*)' -Properties city, state |  Select-Object * |  ForEach-Object {Set-ADObject -Identity $_.DistinguishedName `  -Replace @{l=$($_.state)}}

【讨论】:

  • 工作。谢谢丽莎
猜你喜欢
  • 2021-07-26
  • 2011-03-23
  • 1970-01-01
  • 1970-01-01
  • 2017-10-20
  • 2011-01-14
  • 2017-10-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多