locked
Unable to get data from multiline text box correctly RRS feed

  • Question

  • I have part of a script I'm doing for work where the user enters in multiple computer names into a multiline text box, but I'm having trouble getting each line. I have it set to Multiline and AcceptReturn is true. Here is what I have so far:

    $buttonPrintBuildSheets_Click={
    	#TODO: Place custom script here
    	$refreshList = $computerNames.Text.Split("`r`n") | % { $_.Trim() }
    	#Write-Debug $refreshList
    	
    	Print-BuildSheets -refreshList $computerNames
    	
    }
    What I'm getting when I run the "split" is "Invalid characters in path", but what I see is that it's putting part of the form type (.Windows.Forms.Textbox) in the path. I'm sure it's minor, but I still need some help.

    Friday, September 22, 2017 3:56 PM

All replies

  • Obviously I'm doing something wrong. I fixed the above line to:

    $buttonPrintBuildSheets_Click={
    	#TODO: Place custom script here
    	#$refreshList = $computerNames.Text.Split("`r`n")
    	#Write-Debug $refreshList
    	
    	Print-BuildSheets -refreshList $([string]$computerNames.Text.ToString().ToUpper())
    	
    }
    

    I'm getting all the lines but when I check element 0 of $refreshList, I only get the first letter of the first item in the text box.

    Friday, September 22, 2017 5:28 PM
  • Use "Lines" to get individual lines in the box.

    "$computerNames.Lines "  is an array of lines.


    \_(ツ)_/

    Friday, September 22, 2017 8:29 PM