我想使用交互式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'"
答案 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)"