Link to home
Start Free TrialLog in
Avatar of Roccat
RoccatFlag for United States of America

asked on

List title next to name in listbox

Can you help me how a users job title next to their name in a list box?  The code below lists all users in one OU.  I would like to list their job title from the job title field next to their name but cant figure out how.

$listbox3.Items.Clear();
	$here3 = Get-ADUser -SearchBase "OU=Staff,OU=Amigos,dc=homelab,dc=com" -Filter * | Get-ADUser -Property DisplayName, title | Select -expandproperty Name
	$here3 = $here3 | sort-object
	load-listbox -Listbox $listbox3 -Items $here3

Open in new window

SOLUTION
Avatar of get-ADuser -F ($_.Name -eq "Todd")
get-ADuser -F ($_.Name -eq "Todd")
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of oBdA
oBdA

Why don't you just use Out-GridView?
And there's no need to stress AD by calling Get-ADUser twice.
$here3 = Get-ADUser -SearchBase "OU=Staff,OU=Amigos,dc=homelab,dc=com" -Filter * -Property DisplayName, title | Sort-Object
$here3 | Out-GridView

Open in new window

When used with -PassThru, it can even be used to let a user select one (-OutputMode Single) or multiple (-OutputMode Multiple) items from the list.
Avatar of Roccat

ASKER

I created a GUI using poweshell studio with a listbox element that gets populated with the code above.  I am not sure how to utilize the gridview and also could not figure out how to use the columns mentioned above. Perhaps this is not something I can figure out with at this time.
Avatar of Roccat

ASKER

Thank you for the tip about not stressing the ad with multiple get-user requests.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Roccat

ASKER

The code snippet does work. Thank you for the example. I just don't know how I could use the out-grid view in my gui. I have attached a picture of what I am working on and I put an arrow pointing to my list box.User generated image