Solved

Adding all users from AD group to list view

Posted on 2016-10-10
2
35 Views
Last Modified: 2016-10-10
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
0
Comment
Question by:Roccat
  • 2
2 Comments
 

Accepted Solution

by:
Roccat earned 0 total points
ID: 41837308
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

0
 

Author Comment

by:Roccat
ID: 41837437
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
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

"Migrate" an SMTP relay receive connector to a new server using info from an old server.
A procedure for exporting installed hotfix details of remote computers using powershell
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question