【问题标题】:Why the Set-ADUser Command not allow to use String with number chars?为什么 Set-ADUser 命令不允许使用带数字字符的字符串?
【发布时间】:2016-11-22 12:17:05
【问题描述】:

嘿,我的 powershell 脚本有问题,但我不知道为什么:/ 我认为我的代码是正确的。

这是我的代码:

Set-ADUser –Identity $usr -add @{"extensionattribute1"="test"} # this work

Set-ADUser –Identity $usr -add @{"extensionattribute1"="test2"} # this not!

为什么我不能在字符串中输入带有数字字符的字符串,但是如果我只使用没有数字字符的字符,它可以工作 O.o

这是我的错误:(德语)

Set-ADUser : Für ein Attribut, das nur einen Wert enthalten kann, wurden mehrere Werte angegeben

这里是英文:

对于一个只有一个值的属性,尝试输入更多的值。

【问题讨论】:

    标签: powershell active-directory attributes


    【解决方案1】:

    使用-add 时,您只能将值添加到空属性。

    填充属性后,您需要使用-replace 而不是-add,如下所示:

    Set-ADUser –Identity $usr -replace @{"extensionattribute1"="test2"}
    

    或者在再次使用-add之前使用-clear删除值

    Set-ADUser –Identity $usr -clear "extensionattribute1"
    Set-ADUser –Identity $usr -add @{"extensionattribute1"="test2"}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-05
      • 2011-01-31
      • 1970-01-01
      • 2021-07-18
      • 1970-01-01
      • 2015-08-15
      相关资源
      最近更新 更多