Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Add-Type -AssemblyName System.Windows.Forms
- $Form = New-Object system.Windows.Forms.Form
- $Form.Text = 'Form'
- $Form.Width = 378
- $Form.Height = 300
- $label2 = New-Object system.windows.Forms.Label
- $label2.Text = 'Enter Username Here:'
- $label2.AutoSize = $true
- $label2.Width = 25
- $label2.Height = 10
- $label2.location = new-object system.drawing.size(11,9)
- $label2.Font = "Microsoft Sans Serif,10"
- $Form.controls.Add($label2)
- $NameTextBox = New-Object system.windows.Forms.TextBox
- $NameTextBox.Width = 100
- $NameTextBox.Height = 20
- $NameTextBox.location = new-object system.drawing.size(169,10)
- $NameTextBox.Font = "Microsoft Sans Serif,10"
- $Form.controls.Add($NameTextBox)
- $Button = New-Object system.windows.Forms.Button
- $Button.Text = 'Get-Memberships'
- $Button.Width = 100
- $Button.Height = 50
- $Button.location = new-object system.drawing.size(4,35)
- $Button.Font = "Microsoft Sans Serif,10"
- $Form.controls.Add($Button)
- $BlankTextBox = New-Object system.windows.Forms.RichTextBox
- $BlankTextBox.Multiline = $true
- $BlankTextBox.Width = 200
- $BlankTextBox.Height = 200
- $BlankTextBox.location = new-object system.drawing.point(125,50)
- $BlankTextBox.Readonly = $true
- $Form.controls.Add($BlankTextBox)
- $Button.Add_Click({
- $BlankTextBox.Text = ''
- $Name=$NameTextBox.Text
- $memberships = Get-ADPrincipalGroupMembership -Identity $Name | select -ExpandProperty Name | Sort
- Foreach ($Group in $memberships) {
- $BlankTextBox.AppendText("$Group`n")
- }
- })
- $Form.ShowDialog()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement