Help on IIS APP Pool Dropdown Menu

Ask your PowerShell-related questions, including questions on cmdlet development!
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.
Locked
mdemirkiran
Posts: 3
Joined: Sun Nov 29, 2020 5:03 am

Help on IIS APP Pool Dropdown Menu

Post by mdemirkiran »

Dears,

I am trying to make a GUI to show IIS APPPool names on dropdown menu.
I can get the app pool names but I cant show in label.
Screenshots are attached.

Thanks in advance.
  1.  
  2.  
  3. Import-Module webadministration -ErrorAction SilentlyContinue
  4.  
  5. Import-Module iisadministration -ErrorAction SilentlyContinue
  6.  
  7. Load-ComboBox $combobox1 (Get-ChildItem -Path IIS:\AppPools | select Name) -DisplayMember "Name"
  8.  
  9.  
  10.  
  11. $combobox1_SelectedIndexChanged={
  12.  
  13.     #TODO: Place custom script here
  14.  
  15.    
  16.  
  17.     Write-Host $ComboBox1.ValueMember
  18.  
  19.     $results = $combobox1_SelectedIndexChanged
  20.  
  21.     $label1.Text = $results;
  22.  
  23.  
  24.  
  25. }
  26.  
  27.  
1 IISAPPPOOL_emptyform.png
1 IISAPPPOOL_emptyform.png (6.05 KiB) Viewed 1363 times
2 IISAPPPOOL_Dropdown.png
2 IISAPPPOOL_Dropdown.png (6.48 KiB) Viewed 1363 times
3 IISAPPPOOL_Labelnotshown.png
3 IISAPPPOOL_Labelnotshown.png (12.58 KiB) Viewed 1363 times
by jvierra » Sun Nov 29, 2020 5:43 am
The correct name and syntax for the helper function is as follows.

Code: Select all

$appPools = Get-ChildItem IIS:\AppPools
Update-ComboBox -ComboBox $combobox1 -Items $appPools -DisplayMember Name
To get a control value into a label do the following:

$label1.Text = $combobox1.Text
Go to full post

jvierra
Posts: 14672
Joined: Tue May 22, 2007 9:57 am
Answers: 6
Has voted: 1 time
Been upvoted: 5 times
Contact:

Re: Help on IIS APP Pool Dropdown Menu

Post by jvierra »

The correct name and syntax for the helper function is as follows.

Code: Select all

$appPools = Get-ChildItem IIS:\AppPools
Update-ComboBox -ComboBox $combobox1 -Items $appPools -DisplayMember Name
To get a control value into a label do the following:

$label1.Text = $combobox1.Text

mdemirkiran
Posts: 3
Joined: Sun Nov 29, 2020 5:03 am

Re: Help on IIS APP Pool Dropdown Menu

Post by mdemirkiran »

Dear jvierra,
Thanks for quick response. I still can't get the label. :(

Import-Module webadministration -ErrorAction SilentlyContinue
Import-Module iisadministration -ErrorAction SilentlyContinue
$appPools = Get-ChildItem IIS:\AppPools| select Name
Update-ComboBox -ComboBox $combobox1 -Items $appPools -DisplayMember Name
$label1.Text = $combobox1.Text

I am also adding psf file.
Attachments
Test_IISDropdown.psf
(16.91 KiB) Downloaded 6 times

mdemirkiran
Posts: 3
Joined: Sun Nov 29, 2020 5:03 am

Re: Help on IIS APP Pool Dropdown Menu

Post by mdemirkiran »

Dear jvierra,

Thanks for showing the road, I am now able to change the label.
  1.  
  2.  
  3. Import-Module webadministration -ErrorAction SilentlyContinue
  4.  
  5. Import-Module iisadministration -ErrorAction SilentlyContinue
  6.  
  7. $appPools = Get-ChildItem IIS:\AppPools| select Name
  8.  
  9. Load-ComboBox $combobox1 (Get-ChildItem -Path IIS:\AppPools | select Name) -DisplayMember "Name"
  10.  
  11. Update-ComboBox -ComboBox $combobox1 -Items $appPools -DisplayMember Name
  12.  
  13.  
  14.  
  15.  
  16.  
  17. $combobox1_SelectedIndexChanged={
  18.  
  19.     #TODO: Place custom script here
  20.  
  21.  
  22.  
  23.     $label1.Text = $combobox1.Text
  24.  
  25. }
  26.  
  27.  

jvierra
Posts: 14672
Joined: Tue May 22, 2007 9:57 am
Answers: 6
Has voted: 1 time
Been upvoted: 5 times
Contact:

Re: Help on IIS APP Pool Dropdown Menu

Post by jvierra »

"select name" is unnecessary. When you learn more about PowerShell and Forms this will become something that will be of great help.

Rule #??? - In programming we never throw anything away. We strive to use other methods to get output to conform to expectations.

Locked