Solved

Adding all users from AD group to list view

Posted on 2016-10-10
2
49 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

Free Webinar: AWS Backup & DR

Join our upcoming webinar with experts from AWS, CloudBerry Lab, and the Town of Edgartown IT to discuss best practices for simplifying online backup management and cutting costs.

Question has a verified solution.

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

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
Synchronize a new Active Directory domain with an existing Office 365 tenant
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

679 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