Hi all,
I am in the process of creating a GUI for our service desk, and I am trying to get it to be all fancy and have different elements depending on the task they are trying to carry out.
Let’s say I have two Group Boxes, each with a set of text boxes.
I have one function, “Check-UserInfo”, which I would like to be able to receive inout from either of those group boxes.
The Click command is so:
$GUIFindButton.Add_Click({Check-UserInfo -USRName $GUIUsernameTextBox.text -ProgressBox $GUIProgressRichTextBox -UserNameBox $GUIUsernameTextBox})
And the function is so:
Function Check-UserInfo {
[CmdletBinding()]
Param (
[Parameter(Mandatory=$True)][string]$USRName,
[Parameter(Mandatory=$True)][string]$ProgressBox,
[Parameter(Mandatory=$True)][string]$UserNameBox
)
$ProgressBox.Text = "Cogitating...`n"
$ProgressBox.Text += "Please stand by..."
$UserNameBox.backcolor="WHITE"
sleep -m 5
IF (Get-Aduser -Filter {NAME -like $USRName})
{
$USR = Get-Aduser -Filter {NAME -like $USRName} -Properties *
}
ELSE
{
$USR = Get-Aduser -Filter {SamAccountName -like $USRName} -Properties *
}
IF (($USR|measure).Count -GT 0)
{
$ProgressBox.Text = "Found $(($USR|Measure).count)...`nPlease stand by while useful information is collected and displayed..."
ForEach ($User in $USR)
{
$SamID = $User.SamAccountName
$ProgressBox.Text += Get-RBUser $SamID | Out-String
$UserNameBox.backcolor="LIME"
}
}
ELSEIF (($USR|measure).Count -LT 1)
{
$ProgressBox.Text = "No such User.`nPlease Try again"
$UserNameBox.backcolor="RED"
}
}
I gather that it is not happy about me trying to pass the name of my elements to it.
Is this even possible? I was looking at whether $This might be a solution, but it doesn’t seem like it.
Any help would be appreciated.