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 2 years and 8 months 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.
hi
I created a new form
added a textbox to it and changed it to multiline and resized it to be big enough
then I changed it to read only and in the code all I put is this:
If you return all properties the result will never fit in a textbox. "$userdata" is an object and not text. YOu must create and format text to add to you textbox.
Run the code at a command prompt and create teh correct output as text. You can use any formatter to crete teh text format you need.
No need to import the AD module
You should add a button to fire your get-aduser event
And as J said, you're trying to pull your entire AD into a single text box
thank you for the quick response, was able to figure it out eventually
now I am facing a different issue, basically what I am doing is a form with a textbox on the top that I can type a username from AD and click load
on the left side it will show the current values of the user from AD and on the right side I need to enter new values and click save and it should save it to AD
but for some reason this code (which work in ISE) don't execute the command
sivandavid wrote: ↑Fri Jul 30, 2021 12:39 pm
thank you for the quick response, was able to figure it out eventually
now I am facing a different issue, basically what I am doing is a form with a textbox on the top that I can type a username from AD and click load
on the left side it will show the current values of the user from AD and on the right side I need to enter new values and click save and it should save it to AD
You cannot click "load". YOu cannot automatically update AD with your code you have to write a whole form of code and design a method to take the form data and use a Set-AdUser to update the object.
I recommend using your search engine to learn about WinForms and the AD CmdLets.
Here are some videos and other resources to help get you started.
An addendum: You cannot edit text and turn into an array of parameters. Guessing will not work. You must first learn both PowerShell and WinForms as well as a deeper understanding of AD CmdLets.
You say the code works in ISE as you possted it but that is clearly impossible.
sorry, I have the entire script working in CLI mode including interactive menus and all and I am trying to build it again in GUI form, I guess I should have upload an image to make it more clear, the load part is working without an issue and I created a different text box next to it for the update and I try to update it same way but it does not execute
I am unable to upload an image as I am new to this forum
jvierra wrote: ↑Fri Jul 30, 2021 8:34 pm
Here is a complete demo of how to update a user object with WinForms.
thank you for going the extra mile to answer my question but I compiled this to EXE and tried it as well and it also don't save the entered fax number, I searched the entire ADSI object for this user and it didn't update
This topic is 2 years and 8 months 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.