Powershell 将ADuser extensionAttribute设置为赢得';不管用,但像头衔这样的东西会管用

Powershell 将ADuser extensionAttribute设置为赢得';不管用,但像头衔这样的东西会管用,powershell,active-directory,Powershell,Active Directory,我正在编写一个简单的脚本,它接受一个已经创建的用户,并根据管理员输入的内容更新一个属性 如果我将extensionAttribute替换为例如title之类的内容,那么代码就可以正常工作,但使用extensionAttributes则不行 我尝试了一些东西和其他ExtensionAttribute,但代码非常简单,可以与其他属性一起使用。我想extensionAttributes需要更多我所缺少的代码 $name = Read-Host "AD Logon Name" $key = Read-H

我正在编写一个简单的脚本,它接受一个已经创建的用户,并根据管理员输入的内容更新一个属性

如果我将
extensionAttribute
替换为例如
title
之类的内容,那么代码就可以正常工作,但使用extensionAttributes则不行

我尝试了一些东西和其他ExtensionAttribute,但代码非常简单,可以与其他属性一起使用。我想extensionAttributes需要更多我所缺少的代码

$name = Read-Host "AD Logon Name"
$key = Read-Host "Azure Key"
Set-ADUser $name -extensionAttribute6 $key -PassThru
Set-ADUser:找不到与参数名称“extensionAttribute6”匹配的参数


即使它存在,也找不到它。

Set ADUser的参数集有限,涵盖了AD中最常用的属性。但是,考虑到现有属性的数量以及AD模式的可扩展性,试图将所有属性表示为参数是不可行的

对于未表示为参数的属性,请使用哈希表参数使用参数
-Add
-Replace

Set-ADUser $name -Replace @{'extensionAttribute6' = $key} -PassThru

谢谢你提供的信息。那在将来会有帮助的。@chupathingy不客气。如果你发现它解决了你的问题,请考虑一下。