Management Groups in Listview

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
bhnuser
Posts: 48
Last visit: Tue Nov 21, 2023 10:33 pm

Management Groups in Listview

Post by bhnuser »

Hello everybody,

i want to create a PowerShell GUI to manage AD User and their Groups. In the attachement you find the .psf.
My question is: How i can edit the Listview that it show me the clicked groups in the right Listview-Group "Add" or "Removed"?
Furthermore i need a way to list all groups which are added or removed in a array. How i can do this?
Last edited by bhnuser on Wed Apr 18, 2018 1:59 am, edited 1 time in total.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Management Groups in Listview

Post by jvierra »

Here is how to correctly load a ListBox from an array of strings:

Code: Select all

	$users = Get-AdUser -SearchBase 'OU=_Global,OU=Country,DC=lenze,DC=com' -Filter *
	[void]$listUsername.Items.AddRange($users.Name)
Use the "SelectedIndexChanged" event of the ListBox to populate the list of groups.

Your full question is very hard to understand. Perhaps just create a simple form showing what you want.

The form post is using "ListBox" and not "ListView"

To display a users groups on a click event just have the click get the user group membership.
User avatar
bhnuser
Posts: 48
Last visit: Tue Nov 21, 2023 10:33 pm

Re: Management Groups in Listview

Post by bhnuser »

I'm so sorry for the bad description!
I will attach a picture of my scenario. Yeah, I know it's a little bit unmanageable.
So, what i want is that there are no duplicate groups appear in the listview, and that I can filter the entries in two arrays, once in an adding-array and once in a deleting-array. In the next step this script should add or remove all listed AD-Groups to or from the person. As I have solved it at the moment, I do not know how to implement it.
Attachments
Admin-Tool.png
Admin-Tool.png (27.61 KiB) Viewed 1751 times
MainForm.psf
(120.11 KiB) Downloaded 123 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Management Groups in Listview

Post by jvierra »

We can answer specific questions which I have as best I can given the request. It is beyond the scope of this and most forums to help you design a solution.

I recommend starting over and simplifying the form. Once you have become familiar with how t implement code in a form using control events and values you will likely begin to understand the limitations and capabilities of a form.

Forms and controls are designed to implement common patterns of usage and data updates. While you can imagine any sort of control layout the implementation may run counter to the intended usage of the controls. This happens often with those new to both PowerShell and Forms. Try starting with a simpler approach or project.

If you search you may still be able to find books discussing how to implement Windows Forms solution.

here are a number of articles that may be of help.
https://www.google.com/search?newwindow ... EOUDu82QYQ
This topic is 6 years old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked