Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

AD search with user input script???

$
0
0

Hi all,

I am new to powershell and was hoping someone could help me out.  I am trying to create a script that will search for user name and phone number in AD.  I was able to get this to work when I specify the user name:

function findNumber
{
 Get-ADUser -filter {name -like 'john*'} -properties ipphone | ft Name, ipphone
}

But when I try to allow for user input it does not return anything, goes back to prompt.

function findNumber ([string]$who)
{
 Get-ADUser -filter {name -like '$who*'} -properties ipphone | ft Name, ipphone
}

also tried this...

function findNumber
{
 $name = Read-Host 'Enter the First Name you would like to search'
 Get-ADUser -filter "name -like '$name'" -properties name, ipphone | ft Name, ipphone
}

Could anyone let me know what I am doing wrong?


Viewing all articles
Browse latest Browse all 6937

Trending Articles