mr.kitkat
Goto Top

Powershell code implementieren

Hallo zusammen,

Ich habe ein Problem mit einem Code. Ich versuchen den Code in das GUI zu implementieren, aber das ganze funktioniert nicht. Habt ihr eventuell Tipps, wie ich das machen könnte?

GUI:
#Generated Form Function
function GenerateForm {
########################################################################
# Code Generated By: SAPIEN Technologies PrimalForms (Community Edition) v1.0.9.0
# Generated On: 05.12.2016 10:36
# Generated By: peamu
########################################################################

#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
$username_textbox = New-Object System.Windows.Forms.TextBox
$username_label = New-Object System.Windows.Forms.Label
$external_label = New-Object System.Windows.Forms.Label
$internal_label = New-Object System.Windows.Forms.Label
$external_textbox = New-Object System.Windows.Forms.RichTextBox
$internal_texbox = New-Object System.Windows.Forms.RichTextBox
$exit_button = New-Object System.Windows.Forms.Button
$disable_button = New-Object System.Windows.Forms.Button
$enable_button = New-Object System.Windows.Forms.Button
$title = New-Object System.Windows.Forms.Label
$InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
#endregion Generated Form Objects

#----------------------------------------------
#Generated Event Script Blocks
#----------------------------------------------
#Provide Custom Code for events specified in PrimalForms.
$exit_button_OnClick= 
{
#TODO: Place custom script here

}

$disable_button_OnClick= 
{
#TODO: Place custom script here

}

$handler_form1_Load= 
{
#TODO: Place custom script here

}

$handler_title_Click= 
{
#TODO: Place custom script here

}

$handler_richTextBox1_TextChanged= 
{
#TODO: Place custom script here

}

$enable_button_OnClick= 
{
#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
$form1.BackColor = [System.Drawing.Color]::FromArgb(255,0,102,204)

$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 777
$System_Drawing_Size.Width = 1171
$form1.ClientSize = $System_Drawing_Size
$form1.DataBindings.DefaultDataSourceUpdateMode = 0
$form1.Name = "form1"  
$form1.Text = "Exchange Autoreply"  
$form1.add_Load($handler_form1_Load)

$username_textbox.DataBindings.DefaultDataSourceUpdateMode = 0
$username_textbox.Font = New-Object System.Drawing.Font("Baskerville Old Face",18,0,3,1)  
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 210
$System_Drawing_Point.Y = 226
$username_textbox.Location = $System_Drawing_Point
$username_textbox.Name = "username_textbox"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 35
$System_Drawing_Size.Width = 187
$username_textbox.Size = $System_Drawing_Size
$username_textbox.TabIndex = 9

$form1.Controls.Add($username_textbox)

$username_label.BackColor = [System.Drawing.Color]::FromArgb(0,255,255,255)
$username_label.DataBindings.DefaultDataSourceUpdateMode = 0
$username_label.Font = New-Object System.Drawing.Font("Baskerville Old Face",18,0,3,1)  

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 42
$System_Drawing_Point.Y = 230
$username_label.Location = $System_Drawing_Point
$username_label.Name = "username_label"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 31
$System_Drawing_Size.Width = 162
$username_label.Size = $System_Drawing_Size
$username_label.TabIndex = 8
$username_label.Text = "Username:"  

$form1.Controls.Add($username_label)

$external_label.BackColor = [System.Drawing.Color]::FromArgb(0,255,255,255)
$external_label.DataBindings.DefaultDataSourceUpdateMode = 0
$external_label.Font = New-Object System.Drawing.Font("Baskerville Old Face",18,0,3,1)  

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 620
$System_Drawing_Point.Y = 429
$external_label.Location = $System_Drawing_Point
$external_label.Name = "external_label"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 33
$System_Drawing_Size.Width = 294
$external_label.Size = $System_Drawing_Size
$external_label.TabIndex = 7
$external_label.Text = "External Message"  

$form1.Controls.Add($external_label)

$internal_label.BackColor = [System.Drawing.Color]::FromArgb(0,255,255,255)
$internal_label.DataBindings.DefaultDataSourceUpdateMode = 0
$internal_label.Font = New-Object System.Drawing.Font("Baskerville Old Face",18,0,3,1)  

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 33
$System_Drawing_Point.Y = 429
$internal_label.Location = $System_Drawing_Point
$internal_label.Name = "internal_label"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 39
$System_Drawing_Size.Width = 550
$internal_label.Size = $System_Drawing_Size
$internal_label.TabIndex = 6
$internal_label.Text = "Internal Message"  

$form1.Controls.Add($internal_label)

$external_textbox.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 620
$System_Drawing_Point.Y = 483
$external_textbox.Location = $System_Drawing_Point
$external_textbox.Name = "external_textbox"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 260
$System_Drawing_Size.Width = 483
$external_textbox.Size = $System_Drawing_Size
$external_textbox.TabIndex = 5
$external_textbox.Text = ""  

$form1.Controls.Add($external_textbox)

$internal_texbox.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 33
$System_Drawing_Point.Y = 483
$internal_texbox.Location = $System_Drawing_Point
$internal_texbox.Name = "internal_texbox"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 260
$System_Drawing_Size.Width = 515
$internal_texbox.Size = $System_Drawing_Size
$internal_texbox.TabIndex = 4
$internal_texbox.Text = ""  
$internal_texbox.add_TextChanged($handler_richTextBox1_TextChanged)

$form1.Controls.Add($internal_texbox)


$exit_button.DataBindings.DefaultDataSourceUpdateMode = 0
$exit_button.Font = New-Object System.Drawing.Font("Baskerville Old Face",18,0,3,1)  

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 931
$System_Drawing_Point.Y = 368
$exit_button.Location = $System_Drawing_Point
$exit_button.Name = "exit_button"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 68
$System_Drawing_Size.Width = 183
$exit_button.Size = $System_Drawing_Size
$exit_button.TabIndex = 3
$exit_button.Text = "exit"  
$exit_button.UseVisualStyleBackColor = $True
$exit_button.add_Click($exit_button_OnClick)

$form1.Controls.Add($exit_button)


$disable_button.DataBindings.DefaultDataSourceUpdateMode = 0
$disable_button.Font = New-Object System.Drawing.Font("Baskerville Old Face",18,0,3,1)  

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 932
$System_Drawing_Point.Y = 285
$disable_button.Location = $System_Drawing_Point
$disable_button.Name = "disable_button"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 58
$System_Drawing_Size.Width = 182
$disable_button.Size = $System_Drawing_Size
$disable_button.TabIndex = 2
$disable_button.Text = "disable"  
$disable_button.UseVisualStyleBackColor = $True
$disable_button.add_Click($disable_button_OnClick)

$form1.Controls.Add($disable_button)


$enable_button.DataBindings.DefaultDataSourceUpdateMode = 0
$enable_button.Font = New-Object System.Drawing.Font("Baskerville Old Face",18,0,3,0)  

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 932
$System_Drawing_Point.Y = 199
$enable_button.Location = $System_Drawing_Point
$enable_button.Name = "enable_button"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 62
$System_Drawing_Size.Width = 183
$enable_button.Size = $System_Drawing_Size
$enable_button.TabIndex = 1
$enable_button.Text = "enable"  
$enable_button.UseVisualStyleBackColor = $True
$enable_button.add_Click($enable_button_OnClick)

$form1.Controls.Add($enable_button)

$title.BackColor = [System.Drawing.Color]::FromArgb(0,255,255,255)
$title.DataBindings.DefaultDataSourceUpdateMode = 0
$title.Font = New-Object System.Drawing.Font("Baskerville Old Face",68,0,3,0)  
$title.ForeColor = [System.Drawing.Color]::FromArgb(255,0,0,0)

$title.ImageAlign = 512
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 61
$System_Drawing_Point.Y = 29
$title.Location = $System_Drawing_Point
$title.Name = "title"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 167
$System_Drawing_Size.Width = 1014
$title.Size = $System_Drawing_Size
$title.TabIndex = 0
$title.Text = "Exchange Autoreply"  
$title.add_Click($handler_title_Click)

$form1.Controls.Add($title)

#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

Funktion:
#===================Variablen======================#
$nachricht = Read-Host "Bitte Ihr Nachricht eingeben"           #Die Abwesensheitnotiz  
$benutzername = Read-Host "Bitte geben Sie Ihr Benutztername eingeben"  

$tag = (get-date -format dddd)                          #Holt den Wochentag

#=====================Verarbeitung==================#

While($true){
    if ($tag -eq "Montag" ) {                              #Schaut ob es Freitag ist  
    
        Set-MailboxAutoReplyConfiguration -Identity $benutzername -AutoReplyState enabled                                    #Aktiviert Autoreply
    
        Set-MailboxAutoReplyConfiguration -Identity $benutzername -ExternalMessage $nachricht -InternalMessage $nachricht    #hinterlegt die Nachticht
        exit
    } else {
        if ($tag -eq "Mittwoch"){                                                                                   #Schaut ob es Mittwoch ist  

            Set-MailboxAutoReplyConfiguration -Identity $benutzername -AutoReplyState disabled                               #Deaktiviert Autoreply
            exit

        }   
    }
    sleep 5h 
}

Content-Key: 324099

Url: https://administrator.de/contentid/324099

Ausgedruckt am: 19.03.2024 um 09:03 Uhr

Mitglied: 131381
131381 16.12.2016 um 14:49:49 Uhr
Goto Top
aber das ganze funktioniert nicht.
Klasse, hunderte Codezeilen hier reinwerfen und keine verständliche Frage stellen was du nicht verstehst und nicht funktioniert bzw. was du überhaupt machen willst! face-sad

Typische Freitagsfrage ...

Gruß
Mitglied: Mr.KitKat
Mr.KitKat 16.12.2016 um 15:02:21 Uhr
Goto Top
Okay also ich versuche diesen Code in das GUI zu implementieren, aber ich weiss nicht genau, wo ich die funktionen intergrieren soll. Ich versuche die Abwesenheitsnotiz mit einem GUI zu erstellen, aber ich weiss nicht welche funktion wo hingehört. Bei den Funktionien wie exitbutton verstehe ich es noch einigermassen, aber bei der While-If schlaufe weiss ich nicht mehr weiter.
Der eigentliche Code im GUI, den ich beachten muss, ist folgender:
#Provide Custom Code for events specified in PrimalForms.
$exit_button_OnClick= 
{
#TODO: Place custom script here

}

$disable_button_OnClick= 
{
#TODO: Place custom script here

}

$handler_form1_Load= 
{
#TODO: Place custom script here

}

$handler_title_Click= 
{
#TODO: Place custom script here

}

$handler_richTextBox1_TextChanged= 
{
#TODO: Place custom script here

}

$enable_button_OnClick= 
{
#TODO: Place custom script here

}

Ich hoffe jetzt ist es ein bisschen verständlicher :3
Mitglied: 131381
Lösung 131381 16.12.2016, aktualisiert am 17.12.2016 um 17:17:10 Uhr
Goto Top
Du siehst doch das das die Events sind die von den entsprechenden Controls getriggert werden, also bspw.
$disable_button_OnClick={ 

}
ist das das Event wenn du den Button Disable in deiner Form anklickst.
Da rein packst du nun deine Set-MailboxAutoreplyconfiguration Befehle mit den angepassten Variablen für den Usernamen $username_textbox.text und für die Nachrichten entsprechend $external_textbox.Text und $internal_textbox.Text. Fertig.

Deine "while-Schlaufe" (Wat is dat fürn Teil?? Haste die bei H&M gekauft?) bringt dir hier nüscht das lässt du besser als separates Skript in der Aufgabenplanung laufen.

Meine Güte GUI zusammenklicken aber null Ahnung 3 Zeilen zu verschieben?!

Ich empfehle dir erst mal mit den Powershell Grundlagen anzufangen, denn so wird das 100%ig nichts vernünftiges.

Naja, komm das wird hier eh nichts mehr mit was beibringen ...

Frohe Weihnachten, skøl
#Generated Form Function
function GenerateForm {

#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
$username_textbox = New-Object System.Windows.Forms.TextBox
$username_label = New-Object System.Windows.Forms.Label
$external_label = New-Object System.Windows.Forms.Label
$internal_label = New-Object System.Windows.Forms.Label
$external_textbox = New-Object System.Windows.Forms.RichTextBox
$internal_texbox = New-Object System.Windows.Forms.RichTextBox
$exit_button = New-Object System.Windows.Forms.Button
$disable_button = New-Object System.Windows.Forms.Button
$enable_button = New-Object System.Windows.Forms.Button
$title = New-Object System.Windows.Forms.Label
$InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
#endregion Generated Form Objects

#----------------------------------------------
#Generated Event Script Blocks
#----------------------------------------------
#Provide Custom Code for events specified in PrimalForms.
$exit_button_OnClick= 
{
    $form1.Close()
}

$disable_button_OnClick= 
{
    
    try{
        Set-MailboxAutoreplyConfiguration -Identity $username_textbox.Text -AutoReplyState disabled -EA Stop
    }catch{
        [System.Windows.Forms.MessageBox]::Show("Fehler: $($_.Exception.Message)","Fehler",0,16)  
    }
}

$handler_form1_Load= 
{

}

$handler_title_Click= 
{

}

$handler_richTextBox1_TextChanged= 
{

}

$enable_button_OnClick= 
{
    try{
        Set-MailboxAutoreplyConfiguration -Identity $username_textbox.Text -AutoReplyState enabled -ExternalMessage $external_textbox.Text -InternalMessage $internal_texbox.text -EA Stop
    }catch{
        [System.Windows.Forms.MessageBox]::Show("Fehler: $($_.Exception.Message)","Fehler",0,16)  
    }
}

$OnLoadForm_StateCorrection=
{#Correct the initial state of the form to prevent the .Net maximized form issue
	$form1.WindowState = $InitialFormWindowState
}

#----------------------------------------------
#region Generated Form Code
$form1.BackColor = [System.Drawing.Color]::FromArgb(255,0,102,204)

$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 777
$System_Drawing_Size.Width = 1171
$form1.ClientSize = $System_Drawing_Size
$form1.DataBindings.DefaultDataSourceUpdateMode = 0
$form1.Name = "form1"  
$form1.Text = "Exchange Autoreply"  
$form1.add_Load($handler_form1_Load)

$username_textbox.DataBindings.DefaultDataSourceUpdateMode = 0
$username_textbox.Font = New-Object System.Drawing.Font("Baskerville Old Face",18,0,3,1)  
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 210
$System_Drawing_Point.Y = 226
$username_textbox.Location = $System_Drawing_Point
$username_textbox.Name = "username_textbox"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 35
$System_Drawing_Size.Width = 187
$username_textbox.Size = $System_Drawing_Size
$username_textbox.TabIndex = 9

$form1.Controls.Add($username_textbox)

$username_label.BackColor = [System.Drawing.Color]::FromArgb(0,255,255,255)
$username_label.DataBindings.DefaultDataSourceUpdateMode = 0
$username_label.Font = New-Object System.Drawing.Font("Baskerville Old Face",18,0,3,1)  

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 42
$System_Drawing_Point.Y = 230
$username_label.Location = $System_Drawing_Point
$username_label.Name = "username_label"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 31
$System_Drawing_Size.Width = 162
$username_label.Size = $System_Drawing_Size
$username_label.TabIndex = 8
$username_label.Text = "Username:"  

$form1.Controls.Add($username_label)

$external_label.BackColor = [System.Drawing.Color]::FromArgb(0,255,255,255)
$external_label.DataBindings.DefaultDataSourceUpdateMode = 0
$external_label.Font = New-Object System.Drawing.Font("Baskerville Old Face",18,0,3,1)  

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 620
$System_Drawing_Point.Y = 429
$external_label.Location = $System_Drawing_Point
$external_label.Name = "external_label"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 33
$System_Drawing_Size.Width = 294
$external_label.Size = $System_Drawing_Size
$external_label.TabIndex = 7
$external_label.Text = "External Message"  

$form1.Controls.Add($external_label)

$internal_label.BackColor = [System.Drawing.Color]::FromArgb(0,255,255,255)
$internal_label.DataBindings.DefaultDataSourceUpdateMode = 0
$internal_label.Font = New-Object System.Drawing.Font("Baskerville Old Face",18,0,3,1)  

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 33
$System_Drawing_Point.Y = 429
$internal_label.Location = $System_Drawing_Point
$internal_label.Name = "internal_label"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 39
$System_Drawing_Size.Width = 550
$internal_label.Size = $System_Drawing_Size
$internal_label.TabIndex = 6
$internal_label.Text = "Internal Message"  

$form1.Controls.Add($internal_label)

$external_textbox.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 620
$System_Drawing_Point.Y = 483
$external_textbox.Location = $System_Drawing_Point
$external_textbox.Name = "external_textbox"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 260
$System_Drawing_Size.Width = 483
$external_textbox.Size = $System_Drawing_Size
$external_textbox.TabIndex = 5
$external_textbox.Text = ""  

$form1.Controls.Add($external_textbox)

$internal_texbox.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 33
$System_Drawing_Point.Y = 483
$internal_texbox.Location = $System_Drawing_Point
$internal_texbox.Name = "internal_texbox"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 260
$System_Drawing_Size.Width = 515
$internal_texbox.Size = $System_Drawing_Size
$internal_texbox.TabIndex = 4
$internal_texbox.Text = ""  
$internal_texbox.add_TextChanged($handler_richTextBox1_TextChanged)

$form1.Controls.Add($internal_texbox)


$exit_button.DataBindings.DefaultDataSourceUpdateMode = 0
$exit_button.Font = New-Object System.Drawing.Font("Baskerville Old Face",18,0,3,1)  

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 931
$System_Drawing_Point.Y = 368
$exit_button.Location = $System_Drawing_Point
$exit_button.Name = "exit_button"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 68
$System_Drawing_Size.Width = 183
$exit_button.Size = $System_Drawing_Size
$exit_button.TabIndex = 3
$exit_button.Text = "exit"  
$exit_button.UseVisualStyleBackColor = $True
$exit_button.add_Click($exit_button_OnClick)

$form1.Controls.Add($exit_button)


$disable_button.DataBindings.DefaultDataSourceUpdateMode = 0
$disable_button.Font = New-Object System.Drawing.Font("Baskerville Old Face",18,0,3,1)  

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 932
$System_Drawing_Point.Y = 285
$disable_button.Location = $System_Drawing_Point
$disable_button.Name = "disable_button"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 58
$System_Drawing_Size.Width = 182
$disable_button.Size = $System_Drawing_Size
$disable_button.TabIndex = 2
$disable_button.Text = "disable"  
$disable_button.UseVisualStyleBackColor = $True
$disable_button.add_Click($disable_button_OnClick)

$form1.Controls.Add($disable_button)


$enable_button.DataBindings.DefaultDataSourceUpdateMode = 0
$enable_button.Font = New-Object System.Drawing.Font("Baskerville Old Face",18,0,3,0)  

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 932
$System_Drawing_Point.Y = 199
$enable_button.Location = $System_Drawing_Point
$enable_button.Name = "enable_button"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 62
$System_Drawing_Size.Width = 183
$enable_button.Size = $System_Drawing_Size
$enable_button.TabIndex = 1
$enable_button.Text = "enable"  
$enable_button.UseVisualStyleBackColor = $True
$enable_button.add_Click($enable_button_OnClick)

$form1.Controls.Add($enable_button)

$title.BackColor = [System.Drawing.Color]::FromArgb(0,255,255,255)
$title.DataBindings.DefaultDataSourceUpdateMode = 0
$title.Font = New-Object System.Drawing.Font("Baskerville Old Face",68,0,3,0)  
$title.ForeColor = [System.Drawing.Color]::FromArgb(255,0,0,0)

$title.ImageAlign = 512
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 61
$System_Drawing_Point.Y = 29
$title.Location = $System_Drawing_Point
$title.Name = "title"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 167
$System_Drawing_Size.Width = 1014
$title.Size = $System_Drawing_Size
$title.TabIndex = 0
$title.Text = "Exchange Autoreply"  
$title.add_Click($handler_title_Click)

$form1.Controls.Add($title)

#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