When I run my app from within PowerShell Studio, the output looks correct.
$VMInfo = Get-AzureRmVmPublicIP -ResourceGroupName $RGVM -VMName $VMip -VMStatus | Select -Property VMNAME, PublicIP
$textboxOutput.AppendText("$VMInfo")
Not sure why it is different after a build.
Brian
After I build it into an .exe and run it, the format doesn't look correct (it is missing the right most fields and looks like it is squished even though there is more space).
Here is the applicable code:Output is formatted differently after build
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.
Re: Output is formatted differently after build
You need to custom format the output. I recommend using a DataGridView as it will auto size better. You can also use Format-Table and set the column widths.
Re: Output is formatted differently after build
Thanks. It looks like no mater how I attempt to format the output, it is still cutting off in the GUI around 80 characters. It is also doing this in the Gridview.
- mxtrinidad
- Posts: 399
- Last visit: Tue May 16, 2023 6:52 am
Re: Output is formatted differently after build
Try the following command as I've seen it working with RichTextBox.
"... | Out-string -width 1000"
Hope this help!
"... | Out-string -width 1000"
Hope this help!
Re: Output is formatted differently after build
For textbox you need to set a compatible fixed font. Be sure to change the form AutoscaleMode to DPI.
The TextBox control does not truncate or expand columns. If you use Out-String the width will get interpreted. Use Format-Table. Also build for Windows Forms latest version.
This code works and displays correctly in all cases. (see attached PSF).
The TextBox control does not truncate or expand columns. If you use Out-String the width will get interpreted. Use Format-Table. Also build for Windows Forms latest version.
This code works and displays correctly in all cases. (see attached PSF).
Code: Select all
$textbox1.Lines = Get-Process |
select * -First 20 |
Format-Table -AutoSize |
Out-String -Width 250
- Attachments
-
- Test-TextBoxFormats.psf
- (25.11 KiB) Downloaded 143 times
Re: Output is formatted differently after build
The default for Out-String is as follows:
help Out-File -Online
Always check the help first:-Width
Specifies the number of characters in each line of output. Any additional characters are truncated, not wrapped. If you omit this parameter, the width is determined by the characteristics of the host program. The default value for the Windows PowerShell console is 80 (characters).+
Type: Int32
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
help Out-File -Online
Re: Output is formatted differently after build
Thanks, I did attempt to use out-string, but it had no effect. Below is my code. I'm surprised that it works fine in the Studio, but not fine once built. Is that normal?
$VMInfoFormated = $VMInfo | Format-Table -AutoSize | Out-String -Width 250
$textboxOutput.AppendText("$VMInfoFormated")
$VMInfoFormated = $VMInfo | Format-Table -AutoSize | Out-String -Width 250
$textboxOutput.AppendText("$VMInfoFormated")
Re: Output is formatted differently after build
Using Format-Table -auto combined with Out-String helps to stabilize the result. Setting DPI mode also helps to maintain translation from PSS to hi-rez monitors. All require using a "fixed" font like "Lucida Console".mxtrinidad wrote: ↑Tue Nov 14, 2017 9:03 am Try the following command as I've seen it working with RichTextBox.
"... | Out-string -width 1000"
Hope this help!
Re: Output is formatted differently after build
Do not use "AppendText". Use $textboxOutput.Lines as this will flow correctly.CitrixITM wrote: ↑Tue Nov 14, 2017 9:29 am Thanks, I did attempt to use out-string, but it had no effect. Below is my code. I'm surprised that it works fine in the Studio, but not fine once built. Is that normal?
$VMInfoFormated = $VMInfo | Format-Table -AutoSize | Out-String -Width 250
$textboxOutput.AppendText("$VMInfoFormated")