Getting a script to write to variable text boxes.

Welcome Forums General PowerShell Q&A Getting a script to write to variable text boxes.

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
3 weeks, 5 days ago.

  • Author
    Posts
  • #103535

    Participant
    Points: 0
    Rank: Member

    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.

  • #103703

    Keymaster
    Points: 7
    Rank: Member

    Since I can't run your code, can you provide a bit more info on which line isn't working, and what it isn't doing that you want it to do?

  • #112747

    Participant
    Points: 0
    Rank: Member

    Hi, thanks for the reply, I must have missed the email that told me I had a reply, sorry :-/

     

    I ended up creating separate elements for each task, and I can't actually remember now what it was I was trying to do here...

You must be logged in to reply to this topic.