Advertisement
Guest User

PowerShell for JeremyLC

a guest
Oct 24th, 2019
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     #Generated Form Function
  2.     function GenerateForm {
  3.     #########################################################################
  4.     # Generated By: u/410th using some code from post by n/JeremyLC
  5.     ########################################################################
  6.    
  7.     #region Import the Assemblies
  8.     [reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
  9.     [reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
  10.     #endregion
  11.    
  12.     #region Generated Form Objects
  13.     $form1 = New-Object System.Windows.Forms.Form
  14.     $label5 = New-Object System.Windows.Forms.Label
  15.     $button2 = New-Object System.Windows.Forms.Button
  16.     $button1 = New-Object System.Windows.Forms.Button
  17.     $label3 = New-Object System.Windows.Forms.Label
  18.     $label2 = New-Object System.Windows.Forms.Label
  19.     $textBox3 = New-Object System.Windows.Forms.TextBox
  20.     $textBox2 = New-Object System.Windows.Forms.TextBox
  21.     $label1 = New-Object System.Windows.Forms.Label
  22.     $textBox1 = New-Object System.Windows.Forms.TextBox
  23.     $InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
  24.     #endregion Generated Form Objects
  25.    
  26.     #----------------------------------------------
  27.     #Generated Event Script Blocks
  28.     #----------------------------------------------
  29.     #Provide Custom Code for events specified in PrimalForms.
  30.     $button1_OnClick=
  31.     {
  32.     $textBox2.Text = "C:\Users\INTERN05\Documents\Sample_Site\"
  33.     $textBox1.Text = ""
  34.     $textBox3.Text = ""
  35.     $richTextBox1.Text = ""
  36.    
  37.     }
  38.    
  39.     $handler_label3_Click=
  40.     {
  41.     #TODO: Place custom script here
  42.    
  43.     }
  44.    
  45.     $handler_label5_Click=
  46.     {
  47.     #TODO: Place custom script here
  48.    
  49.     }
  50.    
  51.    
  52.     $handler_textBox2_TextChanged=
  53.     {
  54.     #TODO: Place custom script here
  55.    
  56.     }
  57.    
  58.     $button2_OnClick=
  59.      {
  60.    
  61.    
  62.    
  63.         param(
  64.             [Parameter(Mandatory = $true)][string]$iiswebsite = $textBox1,
  65.             [Parameter(Mandatory = $true)][string]$path = $textBox2,
  66.             [Parameter(Mandatory = $true)][string]$apppoolName = $textbox3
  67.         )
  68.         Import-Module Webadministration
  69.         cd IIS:\AppPools
  70.         if (-Not(Test-Path $apppoolName -PathType Any)) {
  71.             $app = New-Item $apppoolName
  72.             $app | Set-ItemProperty -Name "managedRuntimeVersion" -Value "No Managed Code"
  73.         }
  74.         cd IIS:\Sites
  75.         $Bindings = @{
  76.             protocol           = "http" ;
  77.             bindingInformation = ":89:";
  78.             serverHostName     = "localhost" + $iiswebsite
  79.         }
  80.         $newweb = New-Item $iiswebsite -Bindings $Bindings -PhysicalPath $path $newweb | Set-ItemProperty -Name "applicationPool" -Value $apppoolName
  81.     }
  82.    
  83.    
  84.    
  85.     $handler_label2_Click=
  86.     {
  87.     #TODO: Place custom script here
  88.    
  89.     }
  90.    
  91.     $handler_label1_Click=
  92.     {
  93.     #TODO: Place custom script here
  94.    
  95.     }
  96.    
  97.     $OnLoadForm_StateCorrection=
  98.     {#Correct the initial state of the form to prevent the .Net maximized form issue
  99.         $form1.WindowState = $InitialFormWindowState
  100.     }
  101.    
  102.     #----------------------------------------------
  103.     #region Generated Form Code
  104.     $System_Drawing_Size = New-Object System.Drawing.Size
  105.     $System_Drawing_Size.Height = 489
  106.     $System_Drawing_Size.Width = 672
  107.     $form1.ClientSize = $System_Drawing_Size
  108.     $form1.DataBindings.DefaultDataSourceUpdateMode = 0
  109.     $form1.Name = "form1"
  110.     $form1.Text = "u/410th"
  111.    
  112.     $label5.DataBindings.DefaultDataSourceUpdateMode = 0
  113.     $label5.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",12,0,3,0)
  114.    
  115.     $System_Drawing_Point = New-Object System.Drawing.Point
  116.     $System_Drawing_Point.X = 222
  117.     $System_Drawing_Point.Y = 9
  118.     $label5.Location = $System_Drawing_Point
  119.     $label5.Name = "label5"
  120.     $System_Drawing_Size = New-Object System.Drawing.Size
  121.     $System_Drawing_Size.Height = 28
  122.     $System_Drawing_Size.Width = 120
  123.     $label5.Size = $System_Drawing_Size
  124.     $label5.Text = "IIS Site Wizard"
  125.     $label5.add_Click($handler_label5_Click)
  126.    
  127.     $form1.Controls.Add($label5)
  128.    
  129.    
  130.     $button2.DataBindings.DefaultDataSourceUpdateMode = 0
  131.    
  132.     $System_Drawing_Point = New-Object System.Drawing.Point
  133.     $System_Drawing_Point.X = 384
  134.     $System_Drawing_Point.Y = 300
  135.     $button2.Location = $System_Drawing_Point
  136.     $button2.Name = "button2"
  137.     $System_Drawing_Size = New-Object System.Drawing.Size
  138.     $System_Drawing_Size.Height = 23
  139.     $System_Drawing_Size.Width = 75
  140.     $button2.TabIndex = 5
  141.     $button2.Size = $System_Drawing_Size
  142.     $button2.Text = "Create Site"
  143.     $button2.UseVisualStyleBackColor = $True
  144.     $button2.add_Click($button2_OnClick)
  145.    
  146.     $form1.Controls.Add($button2)
  147.    
  148.    
  149.     $button1.DataBindings.DefaultDataSourceUpdateMode = 0
  150.    
  151.     $System_Drawing_Point = New-Object System.Drawing.Point
  152.     $System_Drawing_Point.X = 127
  153.     $System_Drawing_Point.Y = 300
  154.     $button1.Location = $System_Drawing_Point
  155.     $button1.Name = "button1"
  156.     $System_Drawing_Size = New-Object System.Drawing.Size
  157.     $System_Drawing_Size.Height = 23
  158.     $System_Drawing_Size.Width = 75
  159.     $button1.Size = $System_Drawing_Size
  160.     $button1.TabIndex = 4
  161.     $button1.Text = "Reset"
  162.     $button1.UseVisualStyleBackColor = $True
  163.     $button1.add_Click($button1_OnClick)
  164.    
  165.     $form1.Controls.Add($button1)
  166.    
  167.    
  168.     $label3.DataBindings.DefaultDataSourceUpdateMode = 0
  169.    
  170.     $System_Drawing_Point = New-Object System.Drawing.Point
  171.     $System_Drawing_Point.X = 49
  172.     $System_Drawing_Point.Y = 249
  173.     $label3.Location = $System_Drawing_Point
  174.     $label3.Name = "label3"
  175.     $System_Drawing_Size = New-Object System.Drawing.Size
  176.     $System_Drawing_Size.Height = 20
  177.     $System_Drawing_Size.Width = 51
  178.     $label3.Size = $System_Drawing_Size
  179.     $label3.Text = "App Pool"
  180.     $label3.add_Click($handler_label3_Click)
  181.    
  182.     $form1.Controls.Add($label3)
  183.    
  184.     $label2.DataBindings.DefaultDataSourceUpdateMode = 0
  185.    
  186.     $System_Drawing_Point = New-Object System.Drawing.Point
  187.     $System_Drawing_Point.X = 49
  188.     $System_Drawing_Point.Y = 145
  189.     $label2.Location = $System_Drawing_Point
  190.     $label2.Name = "label2"
  191.     $System_Drawing_Size = New-Object System.Drawing.Size
  192.     $System_Drawing_Size.Height = 24
  193.     $System_Drawing_Size.Width = 51
  194.     $label2.Size = $System_Drawing_Size
  195.     $label2.Text = "Path"
  196.     $label2.add_Click($handler_label2_Click)
  197.    
  198.     $form1.Controls.Add($label2)
  199.    
  200.     $textBox3.DataBindings.DefaultDataSourceUpdateMode = 0
  201.     $System_Drawing_Point = New-Object System.Drawing.Point
  202.     $System_Drawing_Point.X = 106
  203.     $System_Drawing_Point.Y = 249
  204.     $textBox3.Location = $System_Drawing_Point
  205.     $textBox3.Name = "textBox3"
  206.     $System_Drawing_Size = New-Object System.Drawing.Size
  207.     $System_Drawing_Size.Height = 20
  208.     $System_Drawing_Size.Width = 396
  209.     $textBox3.Size = $System_Drawing_Size
  210.     $textBox3.TabIndex = 2
  211.    
  212.     $form1.Controls.Add($textBox3)
  213.    
  214.     $textBox2.DataBindings.DefaultDataSourceUpdateMode = 0
  215.     $System_Drawing_Point = New-Object System.Drawing.Point
  216.     $System_Drawing_Point.X = 106
  217.     $System_Drawing_Point.Y = 145
  218.     $textBox2.Location = $System_Drawing_Point
  219.     $textBox2.Name = "textBox2"
  220.     $System_Drawing_Size = New-Object System.Drawing.Size
  221.     $System_Drawing_Size.Height = 20
  222.     $System_Drawing_Size.Width = 396
  223.     $textBox2.Size = $System_Drawing_Size
  224.     $textBox2.TabIndex = 1
  225.     $textBox2.Text = "C:\Users\INTERN05\Documents\Sample_Site\"
  226.     $textBox2.add_TextChanged($handler_textBox2_TextChanged)
  227.    
  228.     $form1.Controls.Add($textBox2)
  229.    
  230.     $label1.DataBindings.DefaultDataSourceUpdateMode = 0
  231.    
  232.     $System_Drawing_Point = New-Object System.Drawing.Point
  233.     $System_Drawing_Point.X = 49
  234.     $System_Drawing_Point.Y = 60
  235.     $label1.Location = $System_Drawing_Point
  236.     $label1.Name = "label1"
  237.     $System_Drawing_Size = New-Object System.Drawing.Size
  238.     $System_Drawing_Size.Height = 17
  239.     $System_Drawing_Size.Width = 51
  240.     $label1.Size = $System_Drawing_Size
  241.     $label1.Text = "Name"
  242.     $label1.add_Click($handler_label1_Click)
  243.    
  244.     $form1.Controls.Add($label1)
  245.    
  246.     $textBox1.DataBindings.DefaultDataSourceUpdateMode = 0
  247.     $System_Drawing_Point = New-Object System.Drawing.Point
  248.     $System_Drawing_Point.X = 106
  249.     $System_Drawing_Point.Y = 60
  250.     $textBox1.Location = $System_Drawing_Point
  251.     $textBox1.Name = "textBox1"
  252.     $System_Drawing_Size = New-Object System.Drawing.Size
  253.     $System_Drawing_Size.Height = 20
  254.     $System_Drawing_Size.Width = 396
  255.     $textBox1.Size = $System_Drawing_Size
  256.     $textBox1.TabIndex = 0
  257.    
  258.     $form1.Controls.Add($textBox1)
  259.    
  260.     #endregion Generated Form Code
  261.    
  262.     #Save the initial state of the form
  263.     $InitialFormWindowState = $form1.WindowState
  264.     #Init the OnLoad event to correct the initial state of the form
  265.     $form1.add_Load($OnLoadForm_StateCorrection)
  266.     #Show the Form
  267.     $form1.ShowDialog()| Out-Null
  268.    
  269.     } #End Function
  270.    
  271.     #Call the Function
  272.     GenerateForm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement