Advertisement
Guest User

Untitled

a guest
Nov 30th, 2016
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     Add-Type -AssemblyName System.Windows.Forms
  2.  
  3.  
  4.     $Form = New-Object system.Windows.Forms.Form
  5.     $Form.Text = 'Form'
  6.     $Form.Width = 378
  7.     $Form.Height = 300
  8.  
  9.  
  10.     $label2 = New-Object system.windows.Forms.Label
  11.     $label2.Text = 'Enter Username Here:'
  12.     $label2.AutoSize = $true
  13.     $label2.Width = 25
  14.     $label2.Height = 10
  15.     $label2.location = new-object system.drawing.size(11,9)
  16.     $label2.Font = "Microsoft Sans Serif,10"
  17.     $Form.controls.Add($label2)
  18.  
  19.  
  20.     $NameTextBox = New-Object system.windows.Forms.TextBox
  21.     $NameTextBox.Width = 100
  22.     $NameTextBox.Height = 20
  23.     $NameTextBox.location = new-object system.drawing.size(169,10)
  24.     $NameTextBox.Font = "Microsoft Sans Serif,10"
  25.     $Form.controls.Add($NameTextBox)
  26.  
  27.  
  28.     $Button = New-Object system.windows.Forms.Button
  29.     $Button.Text = 'Get-Memberships'
  30.     $Button.Width = 100
  31.     $Button.Height = 50
  32.     $Button.location = new-object system.drawing.size(4,35)
  33.     $Button.Font = "Microsoft Sans Serif,10"
  34.     $Form.controls.Add($Button)
  35.  
  36.  
  37.     $BlankTextBox = New-Object system.windows.Forms.RichTextBox
  38.     $BlankTextBox.Multiline = $true
  39.     $BlankTextBox.Width = 200
  40.     $BlankTextBox.Height = 200
  41.     $BlankTextBox.location = new-object system.drawing.point(125,50)
  42.     $BlankTextBox.Readonly = $true
  43.     $Form.controls.Add($BlankTextBox)
  44.  
  45.  
  46.  
  47.     $Button.Add_Click({
  48.  
  49.     $BlankTextBox.Text = ''
  50.  
  51.     $Name=$NameTextBox.Text
  52.  
  53.     $memberships = Get-ADPrincipalGroupMembership -Identity $Name | select -ExpandProperty Name | Sort
  54.  
  55.     Foreach ($Group in $memberships) {
  56.  
  57.     $BlankTextBox.AppendText("$Group`n")
  58. }
  59.  
  60.  
  61.  
  62.     })
  63.  
  64.  
  65.  
  66.  
  67.     $Form.ShowDialog()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement