使用 powershell 在 AD 中获取组织职位

Rad*_*ast 4 powershell active-directory

我到处搜索,尝试了许多不同的组合,但我似乎无法弄清楚如何从AD的组织部分获得“职位”。

这是我尝试过的一些事情

get-aduser -Filter * -SearchBase "Bob.Barker" -Properties sAMAccountName,Title

Get-ADUser -identity "Bob.Barker" -Filter * -Properties title | group title -NoElement 
Run Code Online (Sandbox Code Playgroud)

另外,作为奖励问题,您将如何设置职位。

谢谢大家的帮助。

Raf*_*Raf 6

在您的示例中,如果用户的用户名是 Bob.Barker,则使用以下命令:

get-aduser -Filter {samAccountName -eq "Bob.Barker"}  -Properties sAMAccountName,Title
Run Code Online (Sandbox Code Playgroud)

或者如果姓氏是巴克

get-aduser -Filter {sn -eq "Barker"}  -Properties sAMAccountName,Title
Run Code Online (Sandbox Code Playgroud)