Can someone please explain to me why I'm unable to write the following to a RichTextBox?
I'm getting input from a text box and then getting a list of services from a server using the following line:
$processServicesOutput = gwmi win32_service -ComputerName ($textBox1.text) | sort DisplayName | ft SystemName,DisplayName,StartMode,State,PathName
Next, I'm trying to output the results to a RichTextBox with line breaks for each line using the following:
foreach ($line in $processServicesOutput) {
$richTextBox1.Appendtext($line+[char]13+[char]10)
I've tested this a few ways and the issue I think the problem has something to do with the characters or compatibility of the additional characters I'm adding with the formatted results. I receive the following error when debugging:
Method invocation failed because [Microsoft.PowerShell.Commands.Internal.Format.FormatEndData] doesn't contain a method named 'op_Addition'.
At D:\xxx\PowerShell\xxx.ps1:32 char:38
+ $richTextBox1.Appendtext($line+ <<<< [char]13+[char]10)
+ CategoryInfo : InvalidOperation: (op_Addition:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
I'm using PrimalForms community edition to generate the GUI code and using PowerGUI Script Editor to debug. Thank you for any help you can give.