Reputation: 629
So take this code:
function populate([string] $group)
{
$listbox.items.clear()
Get-ADGroup -filter {cn -like "*$group*"} |
foreach {$listbox.items.add($_.DistinguishedName)}
}
$go.Add_Click(
{
populate -group $text.text
})
I'm trying to take the variable $group
and pass it to {cn -like "*$group*"}
but I can't get it to work. Does anybody have any ideas?
Thanks
Upvotes: 1
Views: 1154
Reputation: 201652
Try this:
$pattern = "*$group*"
Get-ADGroup -filter {cn -like $pattern} ...
Upvotes: 1