Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Add-Type -assembly System.Windows.Forms
  2. $main_form = New-Object System.Windows.Forms.Form
  3. $main_form.Text ='MDunns Amazing Distro Helper'
  4.  
  5. $main_form.Width = 600
  6.  
  7. $main_form.Height = 400
  8.  
  9. $main_form.AutoSize = $true
  10.  
  11.  
  12. $Label1 = New-Object System.Windows.Forms.Label
  13.  
  14. $Label1.Text = "Enter Distribution List SAMAccountName"
  15.  
  16. $Label1.Location  = New-Object System.Drawing.Point(0,10)
  17.  
  18. $Label1.AutoSize = $true
  19.  
  20. $main_form.Controls.Add($Label1)
  21.  
  22.  
  23.  
  24. $Textbox1 = New-Object System.Windows.Forms.TextBox
  25.  
  26. $Textbox1.Width = 300
  27.  
  28. $TextBox1.Location  = New-Object System.Drawing.Point(230,10)
  29.  
  30. $main_form.Controls.Add($TextBox1)
  31.  
  32.  
  33. $Button1 = New-Object System.Windows.Forms.Button
  34.  
  35. $Button1.Location = New-Object System.Drawing.Size(600,10)
  36.  
  37. $Button1.Size = New-Object System.Drawing.Size(120,23)
  38.  
  39. $Button1.Text = "Check Name"
  40.  
  41. $main_form.Controls.Add($Button1)
  42.  
  43.  
  44. $Label2 = New-Object System.Windows.Forms.Label
  45.  
  46. $Label2.Text = ""
  47.  
  48. $Label2.Location  = New-Object System.Drawing.Point(110,40)
  49.  
  50. $Label2.AutoSize = $true
  51.  
  52. $main_form.Controls.Add($Label2)
  53.  
  54.  
  55. $Button1.Add_Click(
  56.  
  57. {
  58.  
  59. $TB1 = Get-ADGroup -Identity $TextBox1.Text
  60.  
  61. if ($TB1.GroupCategory -eq 'Distribution'){
  62.  
  63. $Label2.Text = "The entered name is the name of a distribution group"
  64. }
  65.  
  66. else {
  67. $Label2.Text = "The entered name is either incorrect or is not a distribution group"
  68. }
  69. }
  70. )
  71.  
  72.  
  73.  
  74. $main_form.ShowDialog()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement