Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. $searchFirstWild = $searchFirst.Text + "*"
  3. $searchLastWild = $searchLast.Text + "*"
  4. $resUsernameSearchQuery += Get-ADUser -Filter {(GivenName -Like $searchFirstWild) -And (Surname -Like $searchLastWild) -And (Enabled -eq "True")} -searchBase $ouEmp -Properties employeeID| Select-Object -ExpandProperty Name
  5.  
  6.     #Seperate each result into array
  7.     $resUserNameSearchArray = $resUserNameSearchQuery.split(' ')
  8.    
  9.     #Set form object variables
  10.     $i = 1
  11.     $xCoord = 440
  12.  
  13.     #Generate employee results
  14.     foreach($account in $resUserNameSearchArray){
  15.         #Set form object variables
  16.         $labelName = "res" + $i
  17.         $accountName = "acct" + $i     
  18.         #Form Variable
  19.  
  20.         Set-Variable -Name $labelName -Value (New-Object System.Windows.Forms.Label)
  21.         (Get-Variable $labelName -ValueOnly).AutoSize = $true
  22.         (Get-Variable $labelName -ValueOnly).Text = "$account"
  23.         (Get-Variable $labelName -ValueOnly).Width = 25
  24.         (Get-Variable $labelName -ValueOnly).Height = 10
  25.         (Get-Variable $labelName -ValueOnly).Location = New-Object system.drawing.point($xCoord,220)
  26.         (Get-Variable $labelName -ValueOnly).Font = "Microsoft San Serif, 10"
  27.         (Get-Variable $labelName -ValueOnly).Add_Click({
  28.             $searchByUsername.Text = "$labelName"
  29.             search-Username
  30.         })
  31.         $HDTools.controls.Add((Get-Variable $labelName -ValueOnly))
  32.         #Increment Variables
  33.         $i = $i + 1
  34.         $xCoord = $xCoord + 75
  35.        
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement