I'm currently programing an administration tool and I could need some help.
I want that every user, starting with "ca" gets imported to the listbox. The Import into the listbox works perfectly fine.
The users I own e.g. are "cambridge", "california" and "call".
$searchuser = "ca"
if(@(Get-ADObject -Filter { sAMAccountname -eq $searchuser }).Count -ge 1){
Get-ADObject -Filter { sAMAccountname -eq $($searchuser) } | foreach{[void]$lstUsers.Items.Add($_.name)}
} else {
[System.Windows.Forms.MessageBox]::Show("No user found.","Error",[System.Windows.Forms.MessageBoxButtons]::OK,[System.Windows.Forms.MessageBoxIcon]::Warning)
}
If I put a single username into the variable it works without any problems but with multiple it doesn't want to work...
Can someone help me out a little?