Noob question on displaying a text string

Hi there

Brand new to UD and trying to mock up a Dashboard to show my manager the things that can be done. One of the things im trying to is convert an Winforms app i created with powershell tha tour helpdesk use and make it as a dashboard?

Its a simple app that takes three varibales

  • $username
  • $computername
  • $date

the date variable is used to find a specific csv while the other two variables are then used as select-string patterns with the result being outputed line by line as there could be multiple entries. The csv has no headers

I can successfully create the UDinput but its the results im struggling with.

Previously it looked like this in the winforms

$Results = foreach (Line in (get-childitem "\\server\share\ST**-$date.csv" -recurse | Select-String -Pattern ā€œ$userNameā€ | Select-String -Pattern ā€œ$ComputerNameā€)) { $Line.line }

$richtextboxresults.text = $results|out-string

any help/examples greatly received

Many thanks

You can do it in two different ways with UD.

You can either replace the input file with a new control.

$Results = foreach (Line in (get-childitem "\\server\share\ST**-$date.csv" -recurse | Select-String -Pattern ā€œ$userNameā€ | Select-String -Pattern ā€œ$ComputerNameā€)) { $Line.line }

New-UDInputAction -Content { New-UDCard -Content { $results|out-string } }

Or you can set a separate control using Set-UDElement.

$Results = foreach (Line in (get-childitem "\\server\share\ST**-$date.csv" -recurse | Select-String -Pattern ā€œ$userNameā€ | Select-String -Pattern ā€œ$ComputerNameā€)) { $Line.line }

Set-UDElement -Id 'outputCard' -Content { $results|out-string  }

If you use the second method, youā€™ll need to create the outputCard on the page along with the New-UDInput.

New-UDCard -Content { } -Id 'outputCard' 

Thank you, is there a preferred method? Or should I say if it was you what would be the way you would look at doing it?

Depends what you are trying to do. If you want the UDInput to remain on the page, use the second method. If you want the UDInput to be replaced with new content, use the second method.

I find the first easier to implement but it does replace the input form.

1 Like

ok thank you iā€™ll have a play and see what i prefer.

thank you for your advice and assistance