Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Generated Form Function
- function GenerateForm {
- #########################################################################
- # Generated By: u/410th using some code from post by n/JeremyLC
- ########################################################################
- #region Import the Assemblies
- [reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
- [reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
- #endregion
- #region Generated Form Objects
- $form1 = New-Object System.Windows.Forms.Form
- $label5 = New-Object System.Windows.Forms.Label
- $button2 = New-Object System.Windows.Forms.Button
- $button1 = New-Object System.Windows.Forms.Button
- $label3 = New-Object System.Windows.Forms.Label
- $label2 = New-Object System.Windows.Forms.Label
- $textBox3 = New-Object System.Windows.Forms.TextBox
- $textBox2 = New-Object System.Windows.Forms.TextBox
- $label1 = New-Object System.Windows.Forms.Label
- $textBox1 = New-Object System.Windows.Forms.TextBox
- $InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
- #endregion Generated Form Objects
- #----------------------------------------------
- #Generated Event Script Blocks
- #----------------------------------------------
- #Provide Custom Code for events specified in PrimalForms.
- $button1_OnClick=
- {
- $textBox2.Text = "C:\Users\INTERN05\Documents\Sample_Site\"
- $textBox1.Text = ""
- $textBox3.Text = ""
- $richTextBox1.Text = ""
- }
- $handler_label3_Click=
- {
- #TODO: Place custom script here
- }
- $handler_label5_Click=
- {
- #TODO: Place custom script here
- }
- $handler_textBox2_TextChanged=
- {
- #TODO: Place custom script here
- }
- $button2_OnClick=
- {
- param(
- [Parameter(Mandatory = $true)][string]$iiswebsite = $textBox1,
- [Parameter(Mandatory = $true)][string]$path = $textBox2,
- [Parameter(Mandatory = $true)][string]$apppoolName = $textbox3
- )
- Import-Module Webadministration
- cd IIS:\AppPools
- if (-Not(Test-Path $apppoolName -PathType Any)) {
- $app = New-Item $apppoolName
- $app | Set-ItemProperty -Name "managedRuntimeVersion" -Value "No Managed Code"
- }
- cd IIS:\Sites
- $Bindings = @{
- protocol = "http" ;
- bindingInformation = ":89:";
- serverHostName = "localhost" + $iiswebsite
- }
- $newweb = New-Item $iiswebsite -Bindings $Bindings -PhysicalPath $path $newweb | Set-ItemProperty -Name "applicationPool" -Value $apppoolName
- }
- $handler_label2_Click=
- {
- #TODO: Place custom script here
- }
- $handler_label1_Click=
- {
- #TODO: Place custom script here
- }
- $OnLoadForm_StateCorrection=
- {#Correct the initial state of the form to prevent the .Net maximized form issue
- $form1.WindowState = $InitialFormWindowState
- }
- #----------------------------------------------
- #region Generated Form Code
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Height = 489
- $System_Drawing_Size.Width = 672
- $form1.ClientSize = $System_Drawing_Size
- $form1.DataBindings.DefaultDataSourceUpdateMode = 0
- $form1.Name = "form1"
- $form1.Text = "u/410th"
- $label5.DataBindings.DefaultDataSourceUpdateMode = 0
- $label5.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",12,0,3,0)
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 222
- $System_Drawing_Point.Y = 9
- $label5.Location = $System_Drawing_Point
- $label5.Name = "label5"
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Height = 28
- $System_Drawing_Size.Width = 120
- $label5.Size = $System_Drawing_Size
- $label5.Text = "IIS Site Wizard"
- $label5.add_Click($handler_label5_Click)
- $form1.Controls.Add($label5)
- $button2.DataBindings.DefaultDataSourceUpdateMode = 0
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 384
- $System_Drawing_Point.Y = 300
- $button2.Location = $System_Drawing_Point
- $button2.Name = "button2"
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Height = 23
- $System_Drawing_Size.Width = 75
- $button2.TabIndex = 5
- $button2.Size = $System_Drawing_Size
- $button2.Text = "Create Site"
- $button2.UseVisualStyleBackColor = $True
- $button2.add_Click($button2_OnClick)
- $form1.Controls.Add($button2)
- $button1.DataBindings.DefaultDataSourceUpdateMode = 0
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 127
- $System_Drawing_Point.Y = 300
- $button1.Location = $System_Drawing_Point
- $button1.Name = "button1"
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Height = 23
- $System_Drawing_Size.Width = 75
- $button1.Size = $System_Drawing_Size
- $button1.TabIndex = 4
- $button1.Text = "Reset"
- $button1.UseVisualStyleBackColor = $True
- $button1.add_Click($button1_OnClick)
- $form1.Controls.Add($button1)
- $label3.DataBindings.DefaultDataSourceUpdateMode = 0
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 49
- $System_Drawing_Point.Y = 249
- $label3.Location = $System_Drawing_Point
- $label3.Name = "label3"
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Height = 20
- $System_Drawing_Size.Width = 51
- $label3.Size = $System_Drawing_Size
- $label3.Text = "App Pool"
- $label3.add_Click($handler_label3_Click)
- $form1.Controls.Add($label3)
- $label2.DataBindings.DefaultDataSourceUpdateMode = 0
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 49
- $System_Drawing_Point.Y = 145
- $label2.Location = $System_Drawing_Point
- $label2.Name = "label2"
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Height = 24
- $System_Drawing_Size.Width = 51
- $label2.Size = $System_Drawing_Size
- $label2.Text = "Path"
- $label2.add_Click($handler_label2_Click)
- $form1.Controls.Add($label2)
- $textBox3.DataBindings.DefaultDataSourceUpdateMode = 0
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 106
- $System_Drawing_Point.Y = 249
- $textBox3.Location = $System_Drawing_Point
- $textBox3.Name = "textBox3"
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Height = 20
- $System_Drawing_Size.Width = 396
- $textBox3.Size = $System_Drawing_Size
- $textBox3.TabIndex = 2
- $form1.Controls.Add($textBox3)
- $textBox2.DataBindings.DefaultDataSourceUpdateMode = 0
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 106
- $System_Drawing_Point.Y = 145
- $textBox2.Location = $System_Drawing_Point
- $textBox2.Name = "textBox2"
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Height = 20
- $System_Drawing_Size.Width = 396
- $textBox2.Size = $System_Drawing_Size
- $textBox2.TabIndex = 1
- $textBox2.Text = "C:\Users\INTERN05\Documents\Sample_Site\"
- $textBox2.add_TextChanged($handler_textBox2_TextChanged)
- $form1.Controls.Add($textBox2)
- $label1.DataBindings.DefaultDataSourceUpdateMode = 0
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 49
- $System_Drawing_Point.Y = 60
- $label1.Location = $System_Drawing_Point
- $label1.Name = "label1"
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Height = 17
- $System_Drawing_Size.Width = 51
- $label1.Size = $System_Drawing_Size
- $label1.Text = "Name"
- $label1.add_Click($handler_label1_Click)
- $form1.Controls.Add($label1)
- $textBox1.DataBindings.DefaultDataSourceUpdateMode = 0
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 106
- $System_Drawing_Point.Y = 60
- $textBox1.Location = $System_Drawing_Point
- $textBox1.Name = "textBox1"
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Height = 20
- $System_Drawing_Size.Width = 396
- $textBox1.Size = $System_Drawing_Size
- $textBox1.TabIndex = 0
- $form1.Controls.Add($textBox1)
- #endregion Generated Form Code
- #Save the initial state of the form
- $InitialFormWindowState = $form1.WindowState
- #Init the OnLoad event to correct the initial state of the form
- $form1.add_Load($OnLoadForm_StateCorrection)
- #Show the Form
- $form1.ShowDialog()| Out-Null
- } #End Function
- #Call the Function
- GenerateForm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement