Of needles and haystacks

Returning from a hiatus (due to life happening while I was making plans) we are taking a little break from AWS and will sprinkle some Powershell. 

After a job role change, thrusting me into deeper and somewhat uncharted waters, I suddenly found myself needing to, among other things, manage things in an Active Directory of a substantial size - i.e. the haystack. The first order of the day was to actually find the object that needed TLC, often by having only partial name or just an idea of what the name would be (because possessing psychic powers is somehow part of everyone's IT job description). 

I came up with this thing that is neither elegant, nor sophisticated (since I am PS apprentice) but it gets the job done locating things. 

 
$displayname = Read-Host "enter name"
    $namelookup = "*$displayname*"
    Get-ADObject -Filter {name -like $namelookup} | select name, objectclass | sort name


 
Hope someone finds it (pun fully intended) useful. More l33T powershell (and Azure stuff) to come...