创建脚本以从AD获取用户特定的详细信息

时间:2019-01-13 06:32:38

标签: powershell active-directory

我想使用交互式Powershell从用户详细信息中获取特定属性 我使用了以下几行,但没有运气

$User = Read-Host -Prompt 'Input the user Initials'
$Mobile = Get-ADuser -Filter {initials -eq "$User"} -Properties * | Select-Object mobile
Write-Host "Phone Number is '$Mobile'"

1 个答案:

答案 0 :(得分:0)

问题出在编码过滤器的方式上。我也改变了一些其他东西。这有效:

$User = Read-Host -Prompt 'Input the user Initials'
$oUser = Get-ADuser -Filter "initials -eq '$User'" -Properties mobile 

Write-Host "Phone Number is $($oUser.mobile)"
相关问题