I'm trying to have an input box to prompt the user to enter the group instead of hard coding it. Thanks in advance.
$users = gc "C:\Users\raw.admin\Documents\PowerShell Scripts\users_list.txt"
foreach($u in $users)
{
Add-ADGroupMember XA-MS_Products -Members $u
}
I found this snipit of someone elses code but I'm not sure how to adapt it for what I want.
function point ($x,$y)
{
New-Object Drawing.Point $x,$y
}
[reflection.assembly]::LoadWithPartialName("System.Drawing") > $null
[reflection.assembly]::LoadWithPartialName("System.Windows.Forms") > $null
$form = New-Object Windows.forms.form
$form.text = "Drive Space Results"
$form.size = point 600 400
$label1 = New-Object Windows.forms.Label
$label1.location = point 225 25
$label1.size = point 300 25
$label1.text = "MASTER DOMAIN ONLY"
$label2 = New-Object Windows.forms.Label
$label2.location = point 25 75
$label2.size = point 120 100
$label2.text = "Enter Server Name:"
$input1 = New-Object Windows.forms.TextBox
$input1.location = point 150 75
$input1.size = point 350 75
$run = New-Object Windows.forms.Button
$run.text="RUN"
$run.Location = point 150 120
$run.size = point 100 50
$run.add_click({
runCall($input1.text)
})
$exit = New-Object Windows.forms.Button
$exit.text="EXIT"
$exit.Location = point 300 120
$exit.size = point 100 50
$exit.add_click({
$form.close()
})
$out = New-Object Windows.forms.TextBox
$out.location = point 25 200
$out.size = point 525 150
$out.Anchor = "bottom"
$out.Multiline = $true
$form.controls.addrange(($label1,$label2,$input1,$run,$exit,$out))
$form.add_shown({$form.Activate()})
$form.ShowDialog()
$form.ShowDialog()to[void] $form.ShowDialog()and add a new line like$xto save the user's input into a variable ($xin this case)