【问题标题】:Powershell Change Organizational Units to Title CasePowershell 将组织单位更改为标题案例
【发布时间】:2021-11-28 15:06:05
【问题描述】:

所以我试图将我的 OU 上的显示名称设置为标题大小写。老板说很难读。

foreach( $item in $ORGOU ) { Set-ADOrganizationalUnit -Identity $item.DistinguishedName -Replace -DisplayName (Get-Culture).TextInfo.ToTitleCase($item.Name.ToLower()) }


Error:
Set-ADOrganizationalUnit : Missing an argument for parameter 'Replace'. Specify a parameter of type
'System.Collections.Hashtable' and try again.
At line:1 char:89
+ ... OrganizationalUnit -Identity $item.DistinguishedName -Replace -Displa ..

【问题讨论】:

  • 那么,您的问题是什么?除了语法不好。
  • 可以在 powershell 中更改 OU 名称吗?

标签: powershell active-directory


【解决方案1】:

Set-AD* cmdlet 为您提供了 2 种语法,您只需选择 一个

要么使用-DisplayName参数:

Set-ADOrganizationalUnit -Identity $item.DistinguishedName -DisplayName (Get-Culture).TextInfo.ToTitleCase($item.Name.ToLower())

或使用-Replace/-Add 参数之一,在这种情况下,您需要提供要设置的属性名称和值的哈希表(这是错误试图暗示的内容):

Set-ADOrganizationalUnit -Identity $item.DistinguishedName -Replace @{description=(Get-Culture).TextInfo.ToTitleCase($item.Name.ToLower())}

【讨论】:

  • 这很好,但是为什么我不能更改OU名称?
  • @celticadmin 我想你会想要Rename-ADObject
  • 谢谢 我刚刚重建了 OU 结构,因为 OU 是空的,带有 Title Case。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-01-14
  • 1970-01-01
  • 2013-07-10
  • 2012-12-02
  • 2021-04-25
  • 1970-01-01
相关资源
最近更新 更多