Search
Home IIS.NET Forums IIS 7 and Above Configuration & Scripting Powershell help, Populate ComboBox with ApplicationPool selection
Last post Aug 08, 2019 09:27 PM by Kyle74
10 Posts
Aug 08, 2019 06:33 PM|Kyle74|LINK
#Imports cmdlets from ServerManager, IIS Web administration, and IIS Administration Import-Module WebAdministration Import-Module IISAdministration Import-Module ServerManager Add-Type -AssemblyName System.Windows.Forms [System.Windows.Forms.Application]::EnableVisualStyles() $WebsiteCreator = New-Object system.Windows.Forms.Form $WebsiteCreator.ClientSize = '453,456' $WebsiteCreator.text = "Website Creator" $WebsiteCreator.TopMost = $false $Label1 = New-Object system.Windows.Forms.Label $Label1.text = "Enter Website Name:" $Label1.AutoSize = $true $Label1.width = 25 $Label1.height = 10 $Label1.location = New-Object System.Drawing.Point(40,33) $Label1.Font = 'Microsoft Sans Serif,10' $SiteName = New-Object system.Windows.Forms.TextBox $SiteName.multiline = $false $SiteName.text = ".sd.gov" $SiteName.width = 152 $SiteName.height = 20 $SiteName.location = New-Object System.Drawing.Point(40,55) $SiteName.Font = 'Microsoft Sans Serif,10' $Label2 = New-Object system.Windows.Forms.Label $Label2.text = "Port:" $Label2.AutoSize = $true $Label2.width = 25 $Label2.height = 10 $Label2.location = New-Object System.Drawing.Point(259,33) $Label2.Font = 'Microsoft Sans Serif,10' $PortNumber = New-Object system.Windows.Forms.TextBox $PortNumber.multiline = $false $PortNumber.text = "80" $PortNumber.width = 100 $PortNumber.height = 20 $PortNumber.location = New-Object System.Drawing.Point(259,55) $PortNumber.Font = 'Microsoft Sans Serif,10' $Binding = New-Object system.Windows.Forms.Label $Binding.text = "Enter the Binding:" $Binding.AutoSize = $true $Binding.width = 25 $Binding.height = 10 $Binding.location = New-Object System.Drawing.Point(40,104) $Binding.Font = 'Microsoft Sans Serif,10' $Header = New-Object system.Windows.Forms.TextBox $Header.multiline = $false $Header.text = ".sd.gov" $Header.width = 150 $Header.height = 20 $Header.location = New-Object System.Drawing.Point(40,133) $Header.Font = 'Microsoft Sans Serif,10' $Label3 = New-Object system.Windows.Forms.Label $Label3.text = "Physical Path:" $Label3.AutoSize = $true $Label3.width = 25 $Label3.height = 10 $Label3.location = New-Object System.Drawing.Point(40,197) $Label3.Font = 'Microsoft Sans Serif,10' $BrowseBtn = New-Object system.Windows.Forms.Button $BrowseBtn.text = "Browse" $BrowseBtn.width = 60 $BrowseBtn.height = 30 $BrowseBtn.location = New-Object System.Drawing.Point(40,254) $BrowseBtn.Font = 'Microsoft Sans Serif,10' $TextBox1 = New-Object system.Windows.Forms.TextBox $TextBox1.multiline = $false $TextBox1.text = "\\state.sd.local\" $TextBox1.width = 186 $TextBox1.height = 20 $TextBox1.location = New-Object System.Drawing.Point(40,224) $TextBox1.Font = 'Microsoft Sans Serif,10' $CancelBtn = New-Object system.Windows.Forms.Button $CancelBtn.text = "Close" $CancelBtn.width = 60 $CancelBtn.height = 30 $CancelBtn.location = New-Object System.Drawing.Point(307,374) $CancelBtn.Font = 'Microsoft Sans Serif,10' $CreateBtn = New-Object system.Windows.Forms.Button $CreateBtn.text = "Create" $CreateBtn.width = 60 $CreateBtn.height = 30 $CreateBtn.location = New-Object System.Drawing.Point(65,374) $CreateBtn.Font = 'Microsoft Sans Serif,10' $Label4 = New-Object system.Windows.Forms.Label $Label4.text = "Choose Application Pool:" $Label4.AutoSize = $true $Label4.width = 25 $Label4.height = 10 $Label4.location = New-Object System.Drawing.Point(259,104) $Label4.Font = 'Microsoft Sans Serif,10' $AppPoolBox = New-Object system.Windows.Forms.ComboBox $AppPoolBox.text = "Application Pool" $AppPoolBox.width = 151 $AppPoolBox.height = 20 $AppPoolBox.location = New-Object System.Drawing.Point(259,133) $AppPoolBox.Font = 'Microsoft Sans Serif,10' $WebsiteCreator.controls.AddRange(@($Label1,$SiteName,$Label2,$PortNumber,$Binding,$Header,$Label3,$BrowseBtn,$TextBox1,$CancelBtn,$CreateBtn,$Label4,$AppPoolBox)) [void]$WebsiteCreator.ShowDialog()
I'm so stuck right now.
I'm trying to make my comboBox populate with a current list of application pools that are on the Webserver, but I don't know how...
Could anyone assist?
I'm sorry, I know the script I posted is long, but there it is, the GUI is built, this is the only piece of the puzzle I'm stuck on.
(GUI code written by Poshgui)
Aug 08, 2019 06:44 PM|Kyle74|LINK
Hmmm, ok I think I'll do something like: $AppPoolGet = get-iisapppool | Select Name
Then
$AppPoolGet.name
Then I'll pass that to the field :)
Ok I got it, thanks!
Aug 08, 2019 07:11 PM|Kyle74|LINK
Hmmm, I'm having issues throwing the values into the combobox, "You cannot call a method on a null-valued expression." I check the variable $AppPoolGet and it's not empty...
Aug 08, 2019 09:27 PM|Kyle74|LINK
Figured it out, I ended up putting the results in an array.
So: $GetAppPools = @(get-IISAppPool | Select Name)
10 Posts
Powershell help, Populate ComboBox with ApplicationPool selection
Aug 08, 2019 06:33 PM|Kyle74|LINK
I'm so stuck right now.
I'm trying to make my comboBox populate with a current list of application pools that are on the Webserver, but I don't know how...
Could anyone assist?
I'm sorry, I know the script I posted is long, but there it is, the GUI is built, this is the only piece of the puzzle I'm stuck on.
(GUI code written by Poshgui)
10 Posts
Re: Powershell help, Populate ComboBox with ApplicationPool selection
Aug 08, 2019 06:44 PM|Kyle74|LINK
Hmmm, ok I think I'll do something like:
$AppPoolGet = get-iisapppool | Select Name
Then
$AppPoolGet.name
Then I'll pass that to the field :)
Ok I got it, thanks!
10 Posts
Re: Powershell help, Populate ComboBox with ApplicationPool selection
Aug 08, 2019 07:11 PM|Kyle74|LINK
Hmmm, I'm having issues throwing the values into the combobox, "You cannot call a method on a null-valued expression."
I check the variable $AppPoolGet and it's not empty...
10 Posts
Re: Powershell help, Populate ComboBox with ApplicationPool selection
Aug 08, 2019 09:27 PM|Kyle74|LINK
Figured it out, I ended up putting the results in an array.
So: $GetAppPools = @(get-IISAppPool | Select Name)