【问题标题】:How can I change the display name in Active Directory with powershell?如何使用 powershell 更改 Active Directory 中的显示名称?
【发布时间】:2018-01-22 10:57:32
【问题描述】:

如何在 Powershell 中更改 Active Directory 中的名称属性?

我想更改“名称”行,但是当我输入以下内容时出现错误:

Set-ADuser -Identity test1 -Name Test 11

错误信息:

Set-ADUser : A parameter cannot be found that matches parameter name 'Name'.
At line:1 char:28
+ Set-ADUser -Identity test1 -Name Test 11
+                            ~~~~~
+ CategoryInfo          : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.ActiveDirectory.Management.Commands.SetADUser

【问题讨论】:

    标签: powershell active-directory


    【解决方案1】:

    您应该使用 cmdlet Rename-ADObject 来更改 AD 对象的名称属性。

    【讨论】:

    • Olaf 在这里说了什么,但也考虑使用-Whatif 参数,它基本上会告诉你如果你没有添加-whatif,你的命令会做什么(这是一个好方法保留您的工作,而不是将整个公司的显示名称重命名为相同的名称!)。
    • 好的,请告诉我。谢谢。
    【解决方案2】:

    如果您想一次性更改帐户的多个属性(例如更改用户名),请将PassThru 参数添加到Set-AdUser,然后通过管道传输到Rename-ADObject:

    Set-ADUser -Identity "test1" -DisplayName "DisplayName" -GivenName "GivenName" -Surname "Surname" -PassThru | Rename-ADObject -NewName "TestAccount1" -PassThru
    

    【讨论】:

      猜你喜欢
      • 2020-06-28
      • 1970-01-01
      • 2021-12-06
      • 2016-04-13
      • 2020-04-12
      • 2023-03-26
      • 2017-01-10
      • 1970-01-01
      • 2017-06-17
      相关资源
      最近更新 更多