Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $searchFirstWild = $searchFirst.Text + "*"
- $searchLastWild = $searchLast.Text + "*"
- $resUsernameSearchQuery += Get-ADUser -Filter {(GivenName -Like $searchFirstWild) -And (Surname -Like $searchLastWild) -And (Enabled -eq "True")} -searchBase $ouEmp -Properties employeeID| Select-Object -ExpandProperty Name
- #Seperate each result into array
- $resUserNameSearchArray = $resUserNameSearchQuery.split(' ')
- #Set form object variables
- $i = 1
- $xCoord = 440
- #Generate employee results
- foreach($account in $resUserNameSearchArray){
- #Set form object variables
- $labelName = "res" + $i
- $accountName = "acct" + $i
- #Form Variable
- Set-Variable -Name $labelName -Value (New-Object System.Windows.Forms.Label)
- (Get-Variable $labelName -ValueOnly).AutoSize = $true
- (Get-Variable $labelName -ValueOnly).Text = "$account"
- (Get-Variable $labelName -ValueOnly).Width = 25
- (Get-Variable $labelName -ValueOnly).Height = 10
- (Get-Variable $labelName -ValueOnly).Location = New-Object system.drawing.point($xCoord,220)
- (Get-Variable $labelName -ValueOnly).Font = "Microsoft San Serif, 10"
- (Get-Variable $labelName -ValueOnly).Add_Click({
- $searchByUsername.Text = "$labelName"
- search-Username
- })
- $HDTools.controls.Add((Get-Variable $labelName -ValueOnly))
- #Increment Variables
- $i = $i + 1
- $xCoord = $xCoord + 75
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement