Forms, text boxes and get-gpo

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.
Tnt48185
Posts: 17
Joined: Fri May 10, 2019 6:28 am

Re: Forms, text boxes and get-gpo

Post by Tnt48185 » Fri May 10, 2019 8:52 am

I forgot to change the get-gpo line to get-gpo -all. The results are the same, this just runs quicker for testing.

jvierra
Posts: 13891
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Forms, text boxes and get-gpo

Post by jvierra » Fri May 10, 2019 8:55 am

Please read the red box at the top of this topic. It asks to post large amounts of code as an attached PS1 file. Copying large amounts of code is almost impossible to do without errors.

Please edit your post with the full code and add it as an attachment

Tnt48185
Posts: 17
Joined: Fri May 10, 2019 6:28 am

Re: Forms, text boxes and get-gpo

Post by Tnt48185 » Fri May 10, 2019 9:04 am

Dang it, and $searchterm = $txtbox.text
Not $txtbox1.text

Tnt48185
Posts: 17
Joined: Fri May 10, 2019 6:28 am

Re: Forms, text boxes and get-gpo

Post by Tnt48185 » Fri May 10, 2019 9:11 am

Ok, reposting as attachment with corrections... just noting however, my red box states to either use select code or attach...
script.txt
(7.57 KiB) Downloaded 16 times

jvierra
Posts: 13891
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Forms, text boxes and get-gpo

Post by jvierra » Fri May 10, 2019 9:11 am

Here is an example of how to enumerate this and create a form that gives you decent feedback. I changed the code to use "All". It is fast and easier to understand.

See attached.

Also take some time to learn how to write PowerShell code. You are copying and guessing which makes things much more difficult for you,
Attachments
gpo_sample.ps1
(1.26 KiB) Downloaded 20 times

jvierra
Posts: 13891
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Forms, text boxes and get-gpo

Post by jvierra » Fri May 10, 2019 9:13 am

Tnt48185 wrote:
Fri May 10, 2019 9:11 am
Ok, reposting as attachment with corrections... just noting however, my red box states to either use select code or attach...script.txt
Post code as a function PS1 file and not just some text. Remember that technical help requires some assistance from the one asking for help to make the job easier for us. We cannot guess at what is in you mind.

Tnt48185
Posts: 17
Joined: Fri May 10, 2019 6:28 am

Re: Forms, text boxes and get-gpo

Post by Tnt48185 » Fri May 10, 2019 9:20 am

I can not attach a .ps1 file as I am blocked from doing so. You can’t change a file extension after downloading??? Thanks for the help but really? It is getting a little ridiculous. It is as though you keep having me re-post until I give up and you never really answer the question...

jvierra
Posts: 13891
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Forms, text boxes and get-gpo

Post by jvierra » Fri May 10, 2019 9:24 am

Tnt48185 wrote:
Fri May 10, 2019 9:20 am
I can not attach a .ps1 file as I am blocked from doing so. You can’t change a file extension after downloading??? Thanks for the help but really? It is getting a little ridiculous. It is as though you keep having me re-post until I give up and you never really answer the question...
Delete the TXT file and upload a new PS1 file. You can't rename a file once uploaded.

Tnt48185
Posts: 17
Joined: Fri May 10, 2019 6:28 am

Re: Forms, text boxes and get-gpo

Post by Tnt48185 » Fri May 10, 2019 9:43 am

I cannot upload a ps1 on my network. It is not allowed by policy. All you have to do is change the dang extension or copy and paste or download, save as....

jvierra
Posts: 13891
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Forms, text boxes and get-gpo

Post by jvierra » Fri May 10, 2019 9:45 am

Tnt48185 wrote:
Fri May 10, 2019 9:43 am
I cannot upload a ps1 on my network. It is not allowed by policy. All you have to do is change the dang extension or copy and paste or download, save as....
Oh. You network won't allow you to "upload" a PS1.

The code I posted should demonstrate everything you need to understand how the code should work.

Locked