# Help with creating text form with 2 questions

**URL:** <https://forums.powershell.org/t/help-with-creating-text-form-with-2-questions/19402>\
**Category:** PowerShell Help\
**Created:** [May 22, 2022, 5:59pm UTC](https://forums.powershell.org/t/help-with-creating-text-form-with-2-questions/19402 "2022-05-22T17:59:46Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexxx55555](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@alexxx55555](https://forums.powershell.org/u/alexxx55555)\
**Post date:** [May 22, 2022, 5:59pm UTC](https://forums.powershell.org/t/help-with-creating-text-form-with-2-questions/19402/1 "2022-05-22T17:59:46Z")

</div>

Hi all,

I create a script that creates a window where you need to select what group you want to create dl/security and after they choose you need to enter the dl name and is working fine but I want to add one more line that will ask for display name but the script skip this part can you assist, please?

```auto
$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(10,20)
$label.Size = New-Object System.Drawing.Size(280,20)
$label.Text = 'Please enter a group name:'
$form.Controls.Add($label)

$textBox = New-Object System.Windows.Forms.TextBox
$textBox.Location = New-Object System.Drawing.Point(10,40)
$textBox.Size = New-Object System.Drawing.Size(260,20)
$form.Controls.Add($textBox)

$form.Topmost = $true

$form.Add_Shown({$textBox.Select()})
$result = $form.ShowDialog()

if ($result -eq [System.Windows.Forms.DialogResult]::OK)
{
   $Name = $textBox.Text
   $Name
  
} if ($RadioButton1.Checked){

$DLPath = "OU=DL,OU=Alex,DC=alex,DC=local"
New-DistributionGroup -Name $Name -DisplayName $name1 -PrimarySmtpAddress $Name@alex.com -OrganizationalUnit $DLPath -SamAccountName $Name
}

```

---

<div class="post-metadata">

**Author:** ![tbingeman](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/tbingeman/32/2122_2.png) [@tbingeman](https://forums.powershell.org/u/tbingeman)\
**Post date:** [May 22, 2022, 6:16pm UTC](https://forums.powershell.org/t/help-with-creating-text-form-with-2-questions/19402/2 "2022-05-22T18:16:15Z")

</div>

I am not seeing a spot wher $name1 is defined anywhere in the code.

---

<div class="post-metadata">

**Author:** ![alexxx55555](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@alexxx55555](https://forums.powershell.org/u/alexxx55555)\
**Post date:** [May 22, 2022, 6:18pm UTC](https://forums.powershell.org/t/help-with-creating-text-form-with-2-questions/19402/3 "2022-05-22T18:18:07Z")

</div>

this is what i want to do add as a text box but don’t know where can you assist?

---

<div class="post-metadata">

**Author:** ![tbingeman](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/tbingeman/32/2122_2.png) [@tbingeman](https://forums.powershell.org/u/tbingeman)\
**Post date:** [May 23, 2022, 5:55am UTC](https://forums.powershell.org/t/help-with-creating-text-form-with-2-questions/19402/4 "2022-05-23T05:55:08Z")

</div>

Using the code you already had written, I just copied the info for Textbox and created the lines for Textbox2.

```auto
$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(10,20)
$label.Size = New-Object System.Drawing.Size(280,20)
$label.Text = 'Please enter a group name:'
$form.Controls.Add($label)

$textBox = New-Object System.Windows.Forms.TextBox
$textBox.Location = New-Object System.Drawing.Point(10,40)
$textBox.Size = New-Object System.Drawing.Size(260,20)
$form.Controls.Add($textBox)

$textBox2 = New-Object System.Windows.Forms.TextBox
$textBox2.Location = New-Object System.Drawing.Point(10,40)
$textBox2.Size = New-Object System.Drawing.Size(260,20)
$form.Controls.Add($textBox2)

$form.Topmost = $true

$form.Add_Shown({$textBox.Select()})
$form.Add_Shown({$textBox2.Select()})
$result = $form.ShowDialog()

if ($result -eq [System.Windows.Forms.DialogResult]::OK)
{
   $Name = $textBox.Text
   $Name
   $Name1 = $textBox2.Text
   $Name1
  
} if ($RadioButton1.Checked){

$DLPath = "OU=DL,OU=Alex,DC=alex,DC=local"
New-DistributionGroup -Name $Name -DisplayName $name1 -PrimarySmtpAddress $Name@alex.com -OrganizationalUnit $DLPath -SamAccountName $Name
}

See how this works for you.

```

---

<div class="post-metadata">

**Author:** ![alexxx55555](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@alexxx55555](https://forums.powershell.org/u/alexxx55555)\
**Post date:** [May 25, 2022, 4:32pm UTC](https://forums.powershell.org/t/help-with-creating-text-form-with-2-questions/19402/5 "2022-05-25T16:32:22Z")

</div>

thank you but I have in my script that its asks first question: “Please enter a group name”

and then i want after the answer that its will ask a new question

any way to add this?

---

<div class="post-metadata">

**Author:** ![tbingeman](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/tbingeman/32/2122_2.png) [@tbingeman](https://forums.powershell.org/u/tbingeman)\
**Post date:** [May 25, 2022, 6:07pm UTC](https://forums.powershell.org/t/help-with-creating-text-form-with-2-questions/19402/6 "2022-05-25T18:07:34Z")

</div>

You can follow the same principle that I did for the text box with the label for the second question. It is just a matter of duplicating the code and updating your variables to match.

---

<div class="post-metadata">

**Author:** ![alexxx55555](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@alexxx55555](https://forums.powershell.org/u/alexxx55555)\
**Post date:** [May 25, 2022, 6:09pm UTC](https://forums.powershell.org/t/help-with-creating-text-form-with-2-questions/19402/7 "2022-05-25T18:09:21Z")

</div>

should I create a new form?

---

<div class="post-metadata">

**Author:** ![tbingeman](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/tbingeman/32/2122_2.png) [@tbingeman](https://forums.powershell.org/u/tbingeman)\
**Post date:** [May 25, 2022, 6:11pm UTC](https://forums.powershell.org/t/help-with-creating-text-form-with-2-questions/19402/8 "2022-05-25T18:11:53Z")

</div>

You should not have to create a new form. Try updating your script with the following:

```auto
$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(10,20)
$label.Size = New-Object System.Drawing.Size(280,20)
$label.Text = 'Please enter a group name:'
$form.Controls.Add($label)

$textBox = New-Object System.Windows.Forms.TextBox
$textBox.Location = New-Object System.Drawing.Point(10,40)
$textBox.Size = New-Object System.Drawing.Size(260,20)
$form.Controls.Add($textBox)

$label2 = New-Object System.Windows.Forms.Label
$label2.Location = New-Object System.Drawing.Point(30,20)
$label2.Size = New-Object System.Drawing.Size(280,20)
$label2.Text = 'Please enter a group name:'
$form.Controls.Add($label2)

$textBox2 = New-Object System.Windows.Forms.TextBox
$textBox2.Location = New-Object System.Drawing.Point(30,40)
$textBox2.Size = New-Object System.Drawing.Size(260,20)
$form.Controls.Add($textBox2)

$form.Topmost = $true

$form.Add_Shown({$textBox.Select()})
$form.Add_Shown({$textBox2.Select()})
$result = $form.ShowDialog()

if ($result -eq [System.Windows.Forms.DialogResult]::OK)
{
   $Name = $textBox.Text
   $Name
   $Name1 = $textBox2.Text
   $Name1
  
} if ($RadioButton1.Checked){

$DLPath = "OU=DL,OU=Alex,DC=alex,DC=local"
New-DistributionGroup -Name $Name -DisplayName $name1 -PrimarySmtpAddress $Name@alex.com -OrganizationalUnit $DLPath -SamAccountName $Name
}

```

---

<div class="post-metadata">

**Author:** ![alexxx55555](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@alexxx55555](https://forums.powershell.org/u/alexxx55555)\
**Post date:** [May 25, 2022, 6:18pm UTC](https://forums.powershell.org/t/help-with-creating-text-form-with-2-questions/19402/9 "2022-05-25T18:18:31Z")

</div>

tried that still its not asking for the second parameter 🥹  
any one else?

---

<div class="post-metadata">

**Author:** ![tbingeman](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/tbingeman/32/2122_2.png) [@tbingeman](https://forums.powershell.org/u/tbingeman)\
**Post date:** [May 25, 2022, 8:02pm UTC](https://forums.powershell.org/t/help-with-creating-text-form-with-2-questions/19402/10 "2022-05-25T20:02:43Z")

</div>

What are you seeing when you run the code?

---

<div class="post-metadata">

**Author:** ![alexxx55555](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@alexxx55555](https://forums.powershell.org/u/alexxx55555)\
**Post date:** [May 26, 2022, 3:34am UTC](https://forums.powershell.org/t/help-with-creating-text-form-with-2-questions/19402/11 "2022-05-26T03:34:56Z")

</div>

the script is not asking for this data

````auto

$label2 = New-Object System.Windows.Forms.Label
$label2.Location = New-Object System.Drawing.Point(10,20)
$label2.Size = New-Object System.Drawing.Size(280,20)
$label2.Text = 'Please enter the Display Name:'
$form.Controls.Add($label2)```
````

---

<div class="post-metadata">

**Author:** ![tbingeman](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/tbingeman/32/2122_2.png) [@tbingeman](https://forums.powershell.org/u/tbingeman)\
**Post date:** [May 26, 2022, 5:45am UTC](https://forums.powershell.org/t/help-with-creating-text-form-with-2-questions/19402/12 "2022-05-26T05:45:11Z")

</div>

Alex,

What happens when you run this code here?

```auto
$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(10,20)
$label.Size = New-Object System.Drawing.Size(280,20)
$label.Text = 'Please enter a group name:'
$form.Controls.Add($label)

$textBox = New-Object System.Windows.Forms.TextBox
$textBox.Location = New-Object System.Drawing.Point(10,40)
$textBox.Size = New-Object System.Drawing.Size(260,20)
$form.Controls.Add($textBox)

$label2 = New-Object System.Windows.Forms.Label
$label2.Location = New-Object System.Drawing.Point(30,20)
$label2.Size = New-Object System.Drawing.Size(280,20)
$label2.Text = 'Please enter the display name you would like:'
$form.Controls.Add($label2)

$textBox2 = New-Object System.Windows.Forms.TextBox
$textBox2.Location = New-Object System.Drawing.Point(30,40)
$textBox2.Size = New-Object System.Drawing.Size(260,20)
$form.Controls.Add($textBox2)

$form.Topmost = $true

$form.Add_Shown({$textBox.Select()})
$form.Add_Shown({$textBox2.Select()})
$result = $form.ShowDialog()

if ($result -eq [System.Windows.Forms.DialogResult]::OK)
{
   $Name = $textBox.Text
   $Name
   $Name1 = $textBox2.Text
   $Name1
  
} if ($RadioButton1.Checked){

$DLPath = "OU=DL,OU=Alex,DC=alex,DC=local"
New-DistributionGroup -Name $Name -DisplayName $name1 -PrimarySmtpAddress $Name@alex.com -OrganizationalUnit $DLPath -SamAccountName $Name
}

```

Please attach a screenshot of what you are seeing so we can help you further.

---

<div class="post-metadata">

**Author:** ![alexxx55555](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@alexxx55555](https://forums.powershell.org/u/alexxx55555)\
**Post date:** [May 26, 2022, 11:11am UTC](https://forums.powershell.org/t/help-with-creating-text-form-with-2-questions/19402/13 "2022-05-26T11:11:34Z")

</div>

![image](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/2X/a/a4a665fdf99768739b9f6de4bc9d4ddc15f1c973.png)  
the script is not asking to enter the second label  
this is my full script:

```auto

# A function to create the form 
function Groups_Form{
    [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
    [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") 
    
    # Set the size of your form
    $Form = New-Object System.Windows.Forms.Form
    $Form.width = 500
    $Form.height = 300
    $Form.Text = "Groups Creation"
 
    # Set the font of the text to be used within the form
    $Font = New-Object System.Drawing.Font("Times New Roman",12)
    $Form.Font = $Font

    # Create a group that will contain your radio buttons
    $MyGroupBox = New-Object System.Windows.Forms.GroupBox
    $MyGroupBox.Location = '40,30'
    $MyGroupBox.size = '400,110'
    $MyGroupBox.text = "What type of group you want to create?"
    
    # Create the collection of radio buttons
    $RadioButton1 = New-Object System.Windows.Forms.RadioButton
    $RadioButton1.Location = '20,40'
    $RadioButton1.size = '350,20'
    $RadioButton1.Checked = $true 
    $RadioButton1.Text = "DL"
 
    $RadioButton2 = New-Object System.Windows.Forms.RadioButton
    $RadioButton2.Location = '20,70'
    $RadioButton2.size = '350,20'
    $RadioButton2.Checked = $false
    $RadioButton2.Text = "Secuirty"
 
 
    # Add an OK button
    $OKButton = new-object System.Windows.Forms.Button
    $OKButton.Location = '130,200'
    $OKButton.Size = '100,40' 
    $OKButton.Text = 'OK'
    $OKButton.DialogResult=[System.Windows.Forms.DialogResult]::OK
 
    #Add a cancel button
    $CancelButton = new-object System.Windows.Forms.Button
    $CancelButton.Location = '255,200'
    $CancelButton.Size = '100,40'
    $CancelButton.Text = "Cancel"
    $CancelButton.DialogResult=[System.Windows.Forms.DialogResult]::Cancel
 
    # Add all the GroupBox controls on one line
    $MyGroupBox.Controls.AddRange(@($Radiobutton1,$RadioButton2))
 
    # Add all the Form controls on one line 
    $form.Controls.AddRange(@($MyGroupBox,$OKButton,$CancelButton))
 
 
    
    # Assign the Accept and Cancel options in the form to the corresponding buttons
    $form.AcceptButton = $OKButton
    $form.CancelButton = $CancelButton
 
    # Activate the form
    $form.Add_Shown({$form.Activate()})    
    
    # Get the results from the button click
    $dialogResult = $form.ShowDialog()

 if ($Form.DialogResult -eq 'Cancel') {
    [void][System.Windows.Forms.MessageBox]::Show("New group creation cancelled!")
}
    # If the OK button is selected
    if ($dialogResult -eq "OK"){
        
        # Check the current state of each radio button and respond accordingly
   $form = New-Object System.Windows.Forms.Form
$form.Text = 'Enter a Group Name'
$form.Size = New-Object System.Drawing.Size(300,200)
$form.StartPosition = 'CenterScreen'

$okButton = New-Object System.Windows.Forms.Button
$okButton.Location = New-Object System.Drawing.Point(75,120)
$okButton.Size = New-Object System.Drawing.Size(75,23)
$okButton.Text = 'OK'
$okButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
$form.AcceptButton = $okButton
$form.Controls.Add($okButton)

$cancelButton = New-Object System.Windows.Forms.Button
$cancelButton.Location = New-Object System.Drawing.Point(150,120)
$cancelButton.Size = New-Object System.Drawing.Size(75,23)
$cancelButton.Text = 'Cancel'
$cancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
$form.CancelButton = $cancelButton
$form.Controls.Add($cancelButton)

label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(10,20)
$label.Size = New-Object System.Drawing.Size(280,20)
$label.Text = 'Please enter a group name:'
$form.Controls.Add($label)

$textBox = New-Object System.Windows.Forms.TextBox
$textBox.Location = New-Object System.Drawing.Point(10,40)
$textBox.Size = New-Object System.Drawing.Size(260,20)
$form.Controls.Add($textBox)

$label2 = New-Object System.Windows.Forms.Label
$label2.Location = New-Object System.Drawing.Point(30,20)
$label2.Size = New-Object System.Drawing.Size(280,20)
$label2.Text = 'Please enter the display name you would like:'
$form.Controls.Add($label2)

$textBox2 = New-Object System.Windows.Forms.TextBox
$textBox2.Location = New-Object System.Drawing.Point(30,40)
$textBox2.Size = New-Object System.Drawing.Size(260,20)
$form.Controls.Add($textBox2)

$form.Topmost = $true

$form.Add_Shown({$textBox.Select()})
$form.Add_Shown({$textBox2.Select()})
$result = $form.ShowDialog()

if ($result -eq [System.Windows.Forms.DialogResult]::OK)
{
   $Name = $textBox.Text
   $Name
   $Name1 = $textBox2.Text
   $Name1
  
} if ($RadioButton1.Checked){

$DLPath = "OU=DL,OU=Alex,DC=alex,DC=local"
New-DistributionGroup -Name $Name -DisplayName $Name1 -PrimarySmtpAddress $Name@alex.com -OrganizationalUnit $DLPath -SamAccountName $Name
}

        elseif ($RadioButton2.Checked){
$Securitypath = "OU=Groups,OU=Alex,DC=alex,DC=local"
New-DistributionGroup -Name $Name -PrimarySmtpAddress $Name@alex.com -Type Security -OrganizationalUnit $Securitypath -SamAccountName $Name
}
       
    }
}
 
# Call the function
Groups_Form

```

---

<div class="post-metadata">

**Author:** ![alexxx55555](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@alexxx55555](https://forums.powershell.org/u/alexxx55555)\
**Post date:** [May 26, 2022, 3:59pm UTC](https://forums.powershell.org/t/help-with-creating-text-form-with-2-questions/19402/14 "2022-05-26T15:59:35Z")

</div>

Any one who can help?

---

<div class="post-metadata">

**Author:** ![tbingeman](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/tbingeman/32/2122_2.png) [@tbingeman](https://forums.powershell.org/u/tbingeman)\
**Post date:** [May 26, 2022, 5:19pm UTC](https://forums.powershell.org/t/help-with-creating-text-form-with-2-questions/19402/15 "2022-05-26T17:19:25Z")

</div>

Alex,

I determined what the issue was. It was only a matter of where the labels and textboxes were being drawn on the form. The below code reflects those simple changes.

```auto
# A function to create the form 
function Groups_Form{
    [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
    [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") 
    
    # Set the size of your form
    $Form = New-Object System.Windows.Forms.Form
    $Form.width = 500
    $Form.height = 300
    $Form.Text = "Groups Creation"
 
    # Set the font of the text to be used within the form
    $Font = New-Object System.Drawing.Font("Times New Roman",12)
    $Form.Font = $Font

    # Create a group that will contain your radio buttons
    $MyGroupBox = New-Object System.Windows.Forms.GroupBox
    $MyGroupBox.Location = '40,30'
    $MyGroupBox.size = '400,110'
    $MyGroupBox.text = "What type of group you want to create?"
    
    # Create the collection of radio buttons
    $RadioButton1 = New-Object System.Windows.Forms.RadioButton
    $RadioButton1.Location = '20,40'
    $RadioButton1.size = '350,20'
    $RadioButton1.Checked = $true 
    $RadioButton1.Text = "DL"
 
    $RadioButton2 = New-Object System.Windows.Forms.RadioButton
    $RadioButton2.Location = '20,70'
    $RadioButton2.size = '350,20'
    $RadioButton2.Checked = $false
    $RadioButton2.Text = "Secuirty"
 
 
    # Add an OK button
    $OKButton = new-object System.Windows.Forms.Button
    $OKButton.Location = '130,200'
    $OKButton.Size = '100,40' 
    $OKButton.Text = 'OK'
    $OKButton.DialogResult=[System.Windows.Forms.DialogResult]::OK
 
    #Add a cancel button
    $CancelButton = new-object System.Windows.Forms.Button
    $CancelButton.Location = '255,200'
    $CancelButton.Size = '100,40'
    $CancelButton.Text = "Cancel"
    $CancelButton.DialogResult=[System.Windows.Forms.DialogResult]::Cancel
 
    # Add all the GroupBox controls on one line
    $MyGroupBox.Controls.AddRange(@($Radiobutton1,$RadioButton2))
 
    # Add all the Form controls on one line 
    $form.Controls.AddRange(@($MyGroupBox,$OKButton,$CancelButton))
 
 
    
    # Assign the Accept and Cancel options in the form to the corresponding buttons
    $form.AcceptButton = $OKButton
    $form.CancelButton = $CancelButton
 
    # Activate the form
    $form.Add_Shown({$form.Activate()})    
    
    # Get the results from the button click
    $dialogResult = $form.ShowDialog()

 if ($Form.DialogResult -eq 'Cancel') {
    [void][System.Windows.Forms.MessageBox]::Show("New group creation cancelled!")
}
    # If the OK button is selected
    if ($dialogResult -eq "OK"){
        
        # Check the current state of each radio button and respond accordingly
   $form = New-Object System.Windows.Forms.Form
$form.Text = 'Enter a Group Name'
$form.Size = New-Object System.Drawing.Size(300,200)
$form.StartPosition = 'CenterScreen'

$okButton = New-Object System.Windows.Forms.Button
$okButton.Location = New-Object System.Drawing.Point(75,120)
$okButton.Size = New-Object System.Drawing.Size(75,23)
$okButton.Text = 'OK'
$okButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
$form.AcceptButton = $okButton
$form.Controls.Add($okButton)

$cancelButton = New-Object System.Windows.Forms.Button
$cancelButton.Location = New-Object System.Drawing.Point(150,120)
$cancelButton.Size = New-Object System.Drawing.Size(75,23)
$cancelButton.Text = 'Cancel'
$cancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
$form.CancelButton = $cancelButton
$form.Controls.Add($cancelButton)

$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(10,20)
$label.Size = New-Object System.Drawing.Size(280,20)
$label.Text = "Please enter a group name:"
$form.Controls.Add($label)

$textBox = New-Object System.Windows.Forms.TextBox
$textBox.Location = New-Object System.Drawing.Point(10,40)
$textBox.Size = New-Object System.Drawing.Size(260,20)
$form.Controls.Add($textBox)

$label2 = New-Object System.Windows.Forms.Label
$label2.Location = New-Object System.Drawing.Point(10,70)
$label2.Size = New-Object System.Drawing.Size(280,20)
$label2.Text = "Please enter the display name you would like:"
$form.Controls.Add($label2)

$textBox2 = New-Object System.Windows.Forms.TextBox
$textBox2.Location = New-Object System.Drawing.Point(10,90)
$textBox2.Size = New-Object System.Drawing.Size(260,20)
$form.Controls.Add($textBox2)

$form.Topmost = $true

$form.Add_Shown({$textBox.Select()})
$form.Add_Shown({$textBox2.Select()})
$result = $form.ShowDialog()

if ($result -eq [System.Windows.Forms.DialogResult]::OK)
{
   $Name = $textBox.Text
   $Name
   $Name1 = $textBox2.Text
   $Name1
  
} if ($RadioButton1.Checked){

$DLPath = "OU=DL,OU=Alex,DC=alex,DC=local"
New-DistributionGroup -Name $Name -DisplayName $Name1 -PrimarySmtpAddress $Name@alex.com -OrganizationalUnit $DLPath -SamAccountName $Name
}

        elseif ($RadioButton2.Checked){
$Securitypath = "OU=Groups,OU=Alex,DC=alex,DC=local"
New-DistributionGroup -Name $Name -PrimarySmtpAddress $Name@alex.com -Type Security -OrganizationalUnit $Securitypath -SamAccountName $Name
}
       
    }
}
 
# Call the function
Groups_Form

```

---

<div class="post-metadata">

**Author:** ![alexxx55555](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@alexxx55555](https://forums.powershell.org/u/alexxx55555)\
**Post date:** [May 26, 2022, 5:39pm UTC](https://forums.powershell.org/t/help-with-creating-text-form-with-2-questions/19402/16 "2022-05-26T17:39:41Z")

</div>

great thank you

its will work

i was looking for a way that i enter the name of the group click on “ok” and then will be next text form to enter display name is anyway to do that?

---

<div class="post-metadata">

**Author:** ![alexxx55555](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@alexxx55555](https://forums.powershell.org/u/alexxx55555)\
**Post date:** [May 28, 2022, 4:42pm UTC](https://forums.powershell.org/t/help-with-creating-text-form-with-2-questions/19402/17 "2022-05-28T16:42:51Z")

</div>

anyone else can help me?

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:17pm UTC](https://forums.powershell.org/t/help-with-creating-text-form-with-2-questions/19402/18 "2024-05-16T20:17:51Z")

</div>


