- $form1_Load={
- #TODO: Initialize Form Controls here
- $SPN = Get-ADComputer MYCOMPUTER -Properties servicePrincipalName | select -ExpandProperty servicePrincipalName
- $textbox1.Text = "$SPN"
- }
Multi-line textbox output
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Multi-line textbox output
Brand new to Powershell Studio and so far loving it. I want to do something seemingly so simple but can't quite figure out how. For testing, I have a single form with one multi-line textbox.
How do I get each result on a new line? Right now it outputs it as one line with a space between each entry.
Re: Multi-line textbox output
Here are the docs. They are linked on the right context menu of each control in the toolbox.
https://info.sapien.com/index.php/guis/ ... ox-control
https://docs.microsoft.com/en-us/dotnet ... mework-4.8
https://info.sapien.com/index.php/guis/ ... ox-control
https://docs.microsoft.com/en-us/dotnet ... mework-4.8
Re: Multi-line textbox output
While that does output servicePrincipalName to the textbox, it outputs as one long line. What I would like is to have it output each servicePrincipalName entry in AD to a newline in the textbox.
Current output in the textbox:
CmRcService/MYCOMPUTER CmRcService/MYCOMPUTER.mydomain.com
Desired output:
CmRcService/MYCOMPUTER
CmRcService/MYCOMPUTER.mydomain.com
Current output in the textbox:
CmRcService/MYCOMPUTER CmRcService/MYCOMPUTER.mydomain.com
Desired output:
CmRcService/MYCOMPUTER
CmRcService/MYCOMPUTER.mydomain.com
Re: Multi-line textbox output
This gives the desired result. Thanks!
- $SPN = Get-ADComputer MYCOMPUTER -Properties servicePrincipalName | select -ExpandProperty servicePrincipalName
- foreach ($item in $SPN)
- {
- $item = $item -split ' '
- $textbox1.AppendText("$($item)`n")
- }
Re: Multi-line textbox output
Now do this:
Code: Select all
$textbox.Lines = Get-ADComputer MYCOMPUTER -Properties servicePrincipalName |
select -ExpandProperty servicePrincipalName |
Out-String
Re: Multi-line textbox output
Well your may might work but it is not the correct way for reasons you will understand as you learn PowerShell and Forms development. The attached file is s simple demo of how this works and how it is useful. It has two methods. OPen and run it to see what I am getting at.
- Attachments
-
- Test-Textbox_Listbox.psf
- (14.86 KiB) Downloaded 201 times