• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 155
  • Last Modified:

Adding all users from AD group to list view

This is my first time looking into using list view in powershell studio.  I am looking to get all users in an active directory group and show them in a list view. After I get the working eventually I would like to be able to select a user in the list view and remove that user from the AD group with a button.

So for now I am just looking for help on how to query AD for a list of users and show them in the list.
Here is the line of code I can use to show the list in the powershell ise. How can I populate a listview object with this list of users?
Get-ADGroupMember -identity "students" -Recursive | Get-ADUser -Property DisplayName | Select Name
  • 2
1 Solution
RoccatAuthor Commented:
This look like it does the trick.

$here = Get-ADGroupMember -identity "yard-students" -recursive | Get-ADUser -Property DisplayName | Select -expandproperty Name
	foreach ($Whole_name in $here)
		Add-ListViewItem -ListView $listview1 -Items $Whole_name

Open in new window

RoccatAuthor Commented:
I ended up changing the listview to listbox

$here = Get-ADGroupMember -identity "yard-students" -recursive | Get-ADUser -Property DisplayName | Select -expandproperty Name
load-listbox -Listbox $listbox1 -Items $here
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

WEBINAR: GDPR Implemented - Tips & Lessons Learned

Join the WatchGuard team on Thursday, March 29th as we recount some valuable lessons learned in weighing the needs of a business against the new regulatory environment, look ahead at the two months left before implementation, and help you understand the steps you can take today!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now