Reputation:
Just installed the PowerShell Studio and I'm trying to view the results of some VMware commands in a richtextbox.
When I run the get-vm
, for example, it shows the data fine (I changed the font to Lucida Console- and it looks ok), regular get-vm
results in the richtext box:
Name : xxx
Cluster : xxx
ESX Host : esx6
Datastore : xxx
MemoryGB : 8
NumCpu : 2
ProvisionedSpace(GB) : 282
UsedSpace(GB) : 281
OS : Microsoft Windows Server 2008 R2 (64-bit)
But when I try to run (get-vm).Guest.Disks
the data not shown good in the richtextbox, it looks like this:
Capacity:192515403776,
FreeSpace:43895230464,
Path:E:\
Capacity:75053920256,
FreeSpace:12630409216,
Path:C:\
when run it in regular powershell console it look like it should:
Volume Capacity(GB) FreeSpace(GB) % FreeSpace
------ ------------ ------------- -----------
E:\ 120 13 11
C:\ 120 15 12
The command line in PowerShell is:
((Get-VM $vm).Guest.disks) | Format-Table @{N="Volume";E={$_.Path}},
@{N="Capacity(GB)";E={[System.Math]::Round($_.CapacityGB)};a="left"},
@{N="FreeSpace(GB)";E={[System.Math]::Round($_.FreeSpaceGB)};a="left"},
@{N="% FreeSpace";E={[math]::Round((100 * ($_.FreeSpacegb / $_.Capacitygb)),0)};a="left"} -auto |
Out-String
the command line in the richtextbox is:
$richtextbox1.AppendText((Get-VM $text).Guest.disks) |
Format-Table @{N="Volume";E={$_.Path}},
@{N="Capacity(GB)";E={[System.Math]::Round($_.CapacityGB)};a="left"},
@{N="FreeSpace(GB)";E={[System.Math]::Round($_.FreeSpaceGB)};a="left"},
@{N="% FreeSpace";E={[math]::Round((100 * ($_.FreeSpacegb / $_.Capacitygb)),0)};a="left"} -auto |
Out-String
How can I get the results like it looks in the PowerShell console wheter is with richtextbox or any other control?
Upvotes: 3
Views: 1747
Reputation: 1
You need to use one of the following fixed size fonts to display the output: Consolas Courier New Lucida Console
Upvotes: 0
Reputation: 200303
Looks like your richtextbox gives you the results in list format. Pipe your results into the Format-Table
cmdlet before piping it into Out-String
to enforce table format:
... | Format-Table | Out-String
Upvotes: 0